mirror of
https://github.com/nushell/nushell
synced 2025-01-14 06:04:09 +00:00
Add version as a flag (#4507)
This commit is contained in:
parent
b8b2737890
commit
f169a9be3b
1 changed files with 12 additions and 0 deletions
12
src/main.rs
12
src/main.rs
|
@ -104,6 +104,7 @@ fn main() -> Result<()> {
|
||||||
|| arg == "--config-file"
|
|| arg == "--config-file"
|
||||||
|| arg == "--perf"
|
|| arg == "--perf"
|
||||||
|| arg == "--threads"
|
|| arg == "--threads"
|
||||||
|
|| arg == "--version"
|
||||||
{
|
{
|
||||||
collect_arg_nushell = true;
|
collect_arg_nushell = true;
|
||||||
}
|
}
|
||||||
|
@ -292,6 +293,16 @@ fn parse_commandline_args(
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if call.has_flag("version") {
|
||||||
|
let _ = std::panic::catch_unwind(move || {
|
||||||
|
let stdout = std::io::stdout();
|
||||||
|
let mut stdout = stdout.lock();
|
||||||
|
let _ = stdout.write_all(env!("CARGO_PKG_VERSION").to_string().as_bytes());
|
||||||
|
});
|
||||||
|
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(NushellCliArgs {
|
return Ok(NushellCliArgs {
|
||||||
redirect_stdin,
|
redirect_stdin,
|
||||||
login_shell,
|
login_shell,
|
||||||
|
@ -335,6 +346,7 @@ impl Command for Nu {
|
||||||
.switch("stdin", "redirect the stdin", None)
|
.switch("stdin", "redirect the stdin", None)
|
||||||
.switch("login", "start as a login shell", Some('l'))
|
.switch("login", "start as a login shell", Some('l'))
|
||||||
.switch("interactive", "start as an interactive shell", Some('i'))
|
.switch("interactive", "start as an interactive shell", Some('i'))
|
||||||
|
.switch("version", "print the version", Some('v'))
|
||||||
.switch(
|
.switch(
|
||||||
"perf",
|
"perf",
|
||||||
"start and print performance metrics during startup",
|
"start and print performance metrics during startup",
|
||||||
|
|
Loading…
Reference in a new issue