Add CLI flag to disable history (#11550)

# Description
Adds a CLI flag for nushell that disables reading and writing to the
history file. This will be useful for future testing and possibly our
users as well. To borrow `fish` shell's terminology, this allows users
to start nushell in "private" mode.

# User-Facing Changes
Breaking API change for `nu-protocol` (changed `Config`).
This commit is contained in:
Ian Manske
2024-01-17 15:40:59 +00:00
committed by GitHub
parent a4199ea312
commit 55bf4d847f
8 changed files with 163 additions and 106 deletions

View File

@@ -98,6 +98,7 @@ pub(crate) fn parse_commandline_args(
#[cfg(feature = "plugin")]
let plugin_file = call.get_flag_expr("plugin-config");
let no_config_file = call.get_named_arg("no-config-file");
let no_history = call.get_named_arg("no-history");
let no_std_lib = call.get_named_arg("no-std-lib");
let config_file = call.get_flag_expr("config");
let env_file = call.get_flag_expr("env-config");
@@ -184,6 +185,7 @@ pub(crate) fn parse_commandline_args(
#[cfg(feature = "plugin")]
plugin_file,
no_config_file,
no_history,
no_std_lib,
config_file,
env_file,
@@ -223,6 +225,7 @@ pub(crate) struct NushellCliArgs {
#[cfg(feature = "plugin")]
pub(crate) plugin_file: Option<Spanned<String>>,
pub(crate) no_config_file: Option<Spanned<String>>,
pub(crate) no_history: Option<Spanned<String>>,
pub(crate) no_std_lib: Option<Spanned<String>>,
pub(crate) config_file: Option<Spanned<String>>,
pub(crate) env_file: Option<Spanned<String>>,
@@ -281,6 +284,11 @@ impl Command for Nu {
"start with no config file and no env file",
Some('n'),
)
.switch(
"no-history",
"disable reading and writing to command history",
None,
)
.switch("no-std-lib", "start with no standard library", None)
.named(
"threads",