forked from extern/nushell
Add environment variable support for modules (#331)
* Add 'expor env' dummy command * (WIP) Abstract away module exportables as Overlay * Switch to Overlays for use/hide Works for decls only right now. * Fix passing import patterns of hide to eval * Simplify use/hide of decls * Add ImportPattern as Expr; Add use env eval Still no parsing of "export env" so I can't test it yet. * Refactor export parsing; Add InternalError * Add env var export and activation; Misc changes Now it is possible to `use` env var that was exported from a module. This commit also adds some new errors and other small changes. * Add env var hiding * Fix eval not recognizing hidden decls Without this change, calling `hide foo`, the evaluator does not know whether a custom command named "foo" was hidden during parsing, therefore, it is not possible to reliably throw an error about the "foo" name not found. * Add use/hide/export env var tests; Cleanup; Notes * Ignore hide env related tests for now * Fix main branch merge mess * Fixed multi-word export def * Fix hiding tests on Windows * Remove env var hiding for now
This commit is contained in:
@ -84,6 +84,18 @@ pub enum ShellError {
|
||||
#[diagnostic(code(nu::shell::variable_not_found), url(docsrs))]
|
||||
VariableNotFoundAtRuntime(#[label = "variable not found"] Span),
|
||||
|
||||
#[error("Environment variable not found")]
|
||||
#[diagnostic(code(nu::shell::variable_not_found), url(docsrs))]
|
||||
EnvVarNotFoundAtRuntime(#[label = "environment variable not found"] Span),
|
||||
|
||||
#[error("Environment variable is not a string")]
|
||||
#[diagnostic(code(nu::shell::variable_not_found), url(docsrs))]
|
||||
EnvVarNotAString(#[label = "does not evaluate to a string"] Span),
|
||||
|
||||
#[error("Not found.")]
|
||||
#[diagnostic(code(nu::parser::not_found), url(docsrs))]
|
||||
NotFound(#[label = "did not find anything under this name"] Span),
|
||||
|
||||
#[error("Can't convert to {0}.")]
|
||||
#[diagnostic(code(nu::shell::cant_convert), url(docsrs))]
|
||||
CantConvert(String, String, #[label("can't convert {1} to {0}")] Span),
|
||||
@ -190,6 +202,10 @@ pub enum ShellError {
|
||||
#[error("Name not found")]
|
||||
#[diagnostic(code(nu::shell::name_not_found), url(docsrs))]
|
||||
DidYouMean(String, #[label("did you mean '{0}'?")] Span),
|
||||
|
||||
#[error("Non-UTF8 string.")]
|
||||
#[diagnostic(code(nu::parser::non_utf8), url(docsrs))]
|
||||
NonUtf8(#[label = "non-UTF8 string"] Span),
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for ShellError {
|
||||
|
Reference in New Issue
Block a user