nushell/crates/nu-command/src/commands/pathvar/mod.rs
Jakub Žádník 2e24de7f47
Support other variables than PATH in pathvar (2nd attempt) (#3828)
* Fix swapped PATH env var separators

* Support pathvar to manipulate other vars than PATH

* Add tests for pathvar and its subcommands

* Adjust pathvar tests to comply with env quirks

* Make pathvar tests work on non-Windows as well

* Compact the comments in pathvar tests

* Fix last failing test

Co-authored-by: Jakub Žádník <jakub.zadnik@tuni.fi>
2021-07-24 11:44:36 -05:00

26 lines
678 B
Rust

pub mod add;
pub mod append;
pub mod command;
pub mod remove;
pub mod reset;
pub mod save;
pub use add::SubCommand as PathvarAdd;
pub use append::SubCommand as PathvarAppend;
pub use command::Command as Pathvar;
pub use remove::SubCommand as PathvarRemove;
pub use reset::SubCommand as PathvarReset;
pub use save::SubCommand as PathvarSave;
use nu_engine::CommandArgs;
use nu_errors::ShellError;
use nu_source::{Tagged, TaggedItem};
use nu_test_support::NATIVE_PATH_ENV_VAR;
fn get_var(args: &CommandArgs) -> Result<Tagged<String>, ShellError> {
Ok(args
.get_flag("var")?
.unwrap_or_else(|| String::from(NATIVE_PATH_ENV_VAR))
.tagged_unknown())
}