forked from extern/nushell
Remove old alias implementation (#8797)
This commit is contained in:
@ -50,13 +50,7 @@ pub fn test_dataframe(cmds: Vec<Box<dyn Command + 'static>>) {
|
||||
|
||||
let (block, delta) = {
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
let output = parse(
|
||||
&mut working_set,
|
||||
None,
|
||||
example.example.as_bytes(),
|
||||
false,
|
||||
&[],
|
||||
);
|
||||
let output = parse(&mut working_set, None, example.example.as_bytes(), false);
|
||||
|
||||
if let Some(err) = working_set.parse_errors.first() {
|
||||
panic!("test parse error in `{}`: {:?}", example.example, err)
|
||||
|
@ -41,7 +41,7 @@ impl Command for Ast {
|
||||
let pipeline: Spanned<String> = call.req(engine_state, stack, 0)?;
|
||||
let mut working_set = StateWorkingSet::new(engine_state);
|
||||
|
||||
let block_output = parse(&mut working_set, None, pipeline.item.as_bytes(), false, &[]);
|
||||
let block_output = parse(&mut working_set, None, pipeline.item.as_bytes(), false);
|
||||
|
||||
let error_output = working_set.parse_errors.first();
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use itertools::Itertools;
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
@ -133,15 +132,6 @@ impl Command for ViewSource {
|
||||
Vec::new(),
|
||||
))
|
||||
}
|
||||
} else if let Some(alias_id) = engine_state.find_alias(val.as_bytes(), &[]) {
|
||||
let contents = &mut engine_state.get_alias(alias_id).iter().map(|span| {
|
||||
String::from_utf8_lossy(engine_state.get_span_contents(span)).to_string()
|
||||
});
|
||||
Ok(Value::String {
|
||||
val: contents.join(" "),
|
||||
span: call.head,
|
||||
}
|
||||
.into_pipeline_data())
|
||||
} else {
|
||||
Err(ShellError::GenericError(
|
||||
"Cannot view value".to_string(),
|
||||
|
@ -65,8 +65,7 @@ impl Command for FromNuon {
|
||||
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
|
||||
let mut block =
|
||||
nu_parser::parse(&mut working_set, None, string_input.as_bytes(), false, &[]);
|
||||
let mut block = nu_parser::parse(&mut working_set, None, string_input.as_bytes(), false);
|
||||
|
||||
if let Some(pipeline) = block.pipelines.get(1) {
|
||||
if let Some(element) = pipeline.elements.get(0) {
|
||||
|
@ -167,7 +167,7 @@ pub fn eval_hook(
|
||||
}
|
||||
|
||||
let output =
|
||||
parse(&mut working_set, Some("hook"), val.as_bytes(), false, &[]);
|
||||
parse(&mut working_set, Some("hook"), val.as_bytes(), false);
|
||||
if let Some(err) = working_set.parse_errors.first() {
|
||||
report_error(&working_set, err);
|
||||
|
||||
|
@ -290,7 +290,7 @@ fn format_record(
|
||||
}
|
||||
}
|
||||
FormatOperation::ValueNeedEval(_col_name, span) => {
|
||||
let exp = parse_expression(working_set, &[*span], &[], false);
|
||||
let exp = parse_expression(working_set, &[*span], false);
|
||||
match working_set.parse_errors.first() {
|
||||
None => {
|
||||
let parsed_result = eval_expression(engine_state, stack, &exp);
|
||||
|
@ -320,7 +320,7 @@ fn parse_module(
|
||||
|
||||
let new_span = Span::new(start, end);
|
||||
let starting_error_count = working_set.parse_errors.len();
|
||||
parse_module_block(working_set, new_span, filename.as_bytes(), &[]);
|
||||
parse_module_block(working_set, new_span, filename.as_bytes());
|
||||
|
||||
if starting_error_count != working_set.parse_errors.len() {
|
||||
if is_debug {
|
||||
@ -354,7 +354,7 @@ fn parse_script(
|
||||
span: Span,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let starting_error_count = working_set.parse_errors.len();
|
||||
parse(working_set, filename, contents, false, &[]);
|
||||
parse(working_set, filename, contents, false);
|
||||
if starting_error_count != working_set.parse_errors.len() {
|
||||
let msg = format!(
|
||||
r#"Found : {}"#,
|
||||
|
@ -1,4 +1,3 @@
|
||||
use itertools::Itertools;
|
||||
use log::trace;
|
||||
use nu_engine::env;
|
||||
use nu_engine::CallExt;
|
||||
@ -74,27 +73,6 @@ fn entry(arg: impl Into<String>, path: impl Into<String>, builtin: bool, span: S
|
||||
Value::Record { cols, vals, span }
|
||||
}
|
||||
|
||||
fn get_entry_in_aliases(engine_state: &EngineState, name: &str, span: Span) -> Option<Value> {
|
||||
if let Some(alias_id) = engine_state.find_alias(name.as_bytes(), &[]) {
|
||||
let alias = engine_state.get_alias(alias_id);
|
||||
let alias_str = alias
|
||||
.iter()
|
||||
.map(|alias_span| String::from_utf8_lossy(engine_state.get_span_contents(alias_span)))
|
||||
.join(" ");
|
||||
|
||||
trace!("Found alias: {}", name);
|
||||
|
||||
Some(entry(
|
||||
name,
|
||||
format!("Nushell alias: {alias_str}"),
|
||||
false,
|
||||
span,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn get_entry_in_commands(engine_state: &EngineState, name: &str, span: Span) -> Option<Value> {
|
||||
if let Some(decl_id) = engine_state.find_decl(name.as_bytes(), &[]) {
|
||||
let (msg, is_builtin) = if engine_state.get_decl(decl_id).is_custom_command() {
|
||||
@ -119,10 +97,6 @@ fn get_entries_in_nu(
|
||||
) -> Vec<Value> {
|
||||
let mut all_entries = vec![];
|
||||
|
||||
if let Some(ent) = get_entry_in_aliases(engine_state, name, span) {
|
||||
all_entries.push(ent);
|
||||
}
|
||||
|
||||
if !all_entries.is_empty() && skip_after_first_found {
|
||||
return all_entries;
|
||||
}
|
||||
|
Reference in New Issue
Block a user