mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Add is-interactive and is-login to NuVariable and allow running scripts with -i (#8306)
Add two rows in `$nu`, `$nu.is-interactive` and `$nu.is-login`, which are true when nu is run in interactive and login mode respectively. The `-i` flag now behaves a bit more like that of bash's, where the any provided command or file is run without REPL but in "interactive mode". This should entail sourcing interactive-mode config files, but since we are planning on overhauling the config system soon, I'm holding off on that. For now, all `-i` does is set `$nu.is-interactive` to be true. About testing, I can't seem to find where cli-args get tested, so I haven't written any new tests for this. Also I don't think there are any docs that need updating. However if I'm wrong please tell me.
This commit is contained in:
@ -37,6 +37,9 @@ impl LazyRecord for NuVariable {
|
||||
cols.push("pid");
|
||||
cols.push("os-info");
|
||||
|
||||
cols.push("is-interactive");
|
||||
cols.push("is-login");
|
||||
|
||||
cols
|
||||
}
|
||||
|
||||
@ -177,6 +180,14 @@ impl LazyRecord for NuVariable {
|
||||
|
||||
Ok(os_record)
|
||||
}
|
||||
"is-interactive" => Ok(Value::Bool {
|
||||
val: self.engine_state.is_interactive,
|
||||
span: self.span,
|
||||
}),
|
||||
"is-login" => Ok(Value::Bool {
|
||||
val: self.engine_state.is_login,
|
||||
span: self.span,
|
||||
}),
|
||||
_ => err(&format!("Could not find column '{column}'")),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user