mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:05:47 +02:00
Allow modules to use
other modules (#6162)
* Allow private imports inside modules Can call `use ...` inside modules now. * Add more tests * Add a leak test * Refactor exportables; Prepare for 'export use' * Fix description * Implement 'export use' command This allows re-exporting module's commands and aliases from another module. * Add more tests; Fix import pattern list strings The import pattern strings didn't trim the surrounding quotes. * Add ignored test
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use crate::{AliasId, BlockId, DeclId};
|
||||
|
||||
pub enum Exportable {
|
||||
Decl(DeclId),
|
||||
Alias(AliasId),
|
||||
EnvVar(BlockId),
|
||||
Decl { name: Vec<u8>, id: DeclId },
|
||||
Alias { name: Vec<u8>, id: AliasId },
|
||||
EnvVar { name: Vec<u8>, id: BlockId },
|
||||
}
|
||||
|
@ -33,16 +33,16 @@ impl Module {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_decl(&mut self, name: &[u8], decl_id: DeclId) -> Option<DeclId> {
|
||||
self.decls.insert(name.to_vec(), decl_id)
|
||||
pub fn add_decl(&mut self, name: Vec<u8>, decl_id: DeclId) -> Option<DeclId> {
|
||||
self.decls.insert(name, decl_id)
|
||||
}
|
||||
|
||||
pub fn add_alias(&mut self, name: &[u8], alias_id: AliasId) -> Option<AliasId> {
|
||||
self.aliases.insert(name.to_vec(), alias_id)
|
||||
pub fn add_alias(&mut self, name: Vec<u8>, alias_id: AliasId) -> Option<AliasId> {
|
||||
self.aliases.insert(name, alias_id)
|
||||
}
|
||||
|
||||
pub fn add_env_var(&mut self, name: &[u8], block_id: BlockId) -> Option<BlockId> {
|
||||
self.env_vars.insert(name.to_vec(), block_id)
|
||||
pub fn add_env_var(&mut self, name: Vec<u8>, block_id: BlockId) -> Option<BlockId> {
|
||||
self.env_vars.insert(name, block_id)
|
||||
}
|
||||
|
||||
pub fn extend(&mut self, other: &Module) {
|
||||
|
Reference in New Issue
Block a user