mirror of
https://github.com/nushell/nushell
synced 2024-12-29 06:23:11 +00:00
Convert ShellError::CommandNotFound to named fields (#11094)
# Description Part of #10700
This commit is contained in:
parent
07d7899a97
commit
08715e6308
5 changed files with 16 additions and 15 deletions
|
@ -95,7 +95,7 @@ You can also learn more at https://www.nushell.sh/book/"#;
|
||||||
result
|
result
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = if let Err(ShellError::CommandNotFound(_)) = result {
|
let result = if let Err(ShellError::CommandNotFound { .. }) = result {
|
||||||
help_modules(engine_state, stack, call)
|
help_modules(engine_state, stack, call)
|
||||||
} else {
|
} else {
|
||||||
result
|
result
|
||||||
|
|
|
@ -114,10 +114,9 @@ pub fn help_commands(
|
||||||
.into_pipeline_data(),
|
.into_pipeline_data(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Err(ShellError::CommandNotFound(span(&[
|
Err(ShellError::CommandNotFound {
|
||||||
rest[0].span,
|
span: span(&[rest[0].span, rest[rest.len() - 1].span]),
|
||||||
rest[rest.len() - 1].span,
|
})
|
||||||
])))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,10 +133,9 @@ pub fn help_externs(
|
||||||
.into_pipeline_data(),
|
.into_pipeline_data(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Err(ShellError::CommandNotFound(span(&[
|
Err(ShellError::CommandNotFound {
|
||||||
rest[0].span,
|
span: span(&[rest[0].span, rest[rest.len() - 1].span]),
|
||||||
rest[rest.len() - 1].span,
|
})
|
||||||
])))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -795,10 +795,10 @@ fn eval_element_with_input(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(ShellError::CommandNotFound(*span))
|
Err(ShellError::CommandNotFound { span: *span })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(ShellError::CommandNotFound(*span)),
|
_ => Err(ShellError::CommandNotFound { span: *span }),
|
||||||
},
|
},
|
||||||
PipelineElement::SeparateRedirection {
|
PipelineElement::SeparateRedirection {
|
||||||
out: (out_span, out_expr),
|
out: (out_span, out_expr),
|
||||||
|
@ -842,14 +842,14 @@ fn eval_element_with_input(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(ShellError::CommandNotFound(*out_span))
|
Err(ShellError::CommandNotFound { span: *out_span })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(_out_other, err_other) => {
|
(_out_other, err_other) => {
|
||||||
if let Expr::String(_) = err_other {
|
if let Expr::String(_) = err_other {
|
||||||
Err(ShellError::CommandNotFound(*out_span))
|
Err(ShellError::CommandNotFound { span: *out_span })
|
||||||
} else {
|
} else {
|
||||||
Err(ShellError::CommandNotFound(*err_span))
|
Err(ShellError::CommandNotFound { span: *err_span })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -685,7 +685,10 @@ pub enum ShellError {
|
||||||
/// Check the spelling for the requested command and try again. Are you sure it's defined and your configurations are loading correctly? Can you execute it?
|
/// Check the spelling for the requested command and try again. Are you sure it's defined and your configurations are loading correctly? Can you execute it?
|
||||||
#[error("Command not found")]
|
#[error("Command not found")]
|
||||||
#[diagnostic(code(nu::shell::command_not_found))]
|
#[diagnostic(code(nu::shell::command_not_found))]
|
||||||
CommandNotFound(#[label("command not found")] Span),
|
CommandNotFound {
|
||||||
|
#[label("command not found")]
|
||||||
|
span: Span,
|
||||||
|
},
|
||||||
|
|
||||||
/// This alias could not be found
|
/// This alias could not be found
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue