mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:45:56 +02:00
Add export alias
and export extern
(#4878)
* export alias * export extern
This commit is contained in:
@ -770,6 +770,19 @@ impl<'a> StateWorkingSet<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn use_aliases(&mut self, aliases: Vec<(Vec<u8>, AliasId)>) {
|
||||
let scope_frame = self
|
||||
.delta
|
||||
.scope
|
||||
.last_mut()
|
||||
.expect("internal error: missing required scope frame");
|
||||
|
||||
for (name, alias_id) in aliases {
|
||||
scope_frame.aliases.insert(name, alias_id);
|
||||
scope_frame.visibility.use_decl_id(&alias_id);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_predecl(&mut self, decl: Box<dyn Command>) -> Option<DeclId> {
|
||||
let name = decl.name().as_bytes().to_vec();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::{BlockId, DeclId};
|
||||
use crate::{AliasId, BlockId, DeclId};
|
||||
|
||||
pub enum Exportable {
|
||||
Decl(DeclId),
|
||||
Alias(AliasId),
|
||||
EnvVar(BlockId),
|
||||
}
|
||||
|
@ -116,6 +116,18 @@ impl Overlay {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn aliases_with_head(&self, head: &[u8]) -> Vec<(Vec<u8>, AliasId)> {
|
||||
self.aliases
|
||||
.iter()
|
||||
.map(|(name, id)| {
|
||||
let mut new_name = head.to_vec();
|
||||
new_name.push(b' ');
|
||||
new_name.extend(name);
|
||||
(new_name, *id)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn alias_names_with_head(&self, head: &[u8]) -> Vec<Vec<u8>> {
|
||||
self.aliases
|
||||
.keys()
|
||||
|
Reference in New Issue
Block a user