mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 09:25:38 +02:00
Cleanup parsing of use and hide commands (#705)
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use super::{Expr, Operator, Statement};
|
||||
use crate::ast::ImportPattern;
|
||||
use crate::{engine::StateWorkingSet, BlockId, Signature, Span, Type, VarId, IN_VARIABLE_ID};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -96,6 +97,13 @@ impl Expression {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_import_pattern(&self) -> Option<ImportPattern> {
|
||||
match &self.expr {
|
||||
Expr::ImportPattern(pattern) => Some(pattern.clone()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_in_variable(&self, working_set: &StateWorkingSet) -> bool {
|
||||
match &self.expr {
|
||||
Expr::BinaryOp(left, _, right) => {
|
||||
|
@ -95,9 +95,9 @@ pub enum ShellError {
|
||||
#[diagnostic(code(nu::shell::variable_not_found), url(docsrs))]
|
||||
VariableNotFoundAtRuntime(#[label = "variable not found"] Span),
|
||||
|
||||
#[error("Environment variable not found")]
|
||||
#[error("Environment variable '{0}' not found")]
|
||||
#[diagnostic(code(nu::shell::env_variable_not_found), url(docsrs))]
|
||||
EnvVarNotFoundAtRuntime(#[label = "environment variable not found"] Span),
|
||||
EnvVarNotFoundAtRuntime(String, #[label = "environment variable not found"] Span),
|
||||
|
||||
#[error("Not found.")]
|
||||
#[diagnostic(code(nu::parser::not_found), url(docsrs))]
|
||||
|
Reference in New Issue
Block a user