mirror of
https://github.com/nushell/nushell.git
synced 2025-07-17 23:02:00 +02:00
Doc file fixes (#14608)
# Description With great thanks to @fdncred and especially @PerchunPak (see #14601) for finding and fixing a number of issues that I pulled in here due to the filename changes and upcoming freeze. This PR primarily fixes a poor wording choice in the new filenames and `config` command options. The fact that these were called `sample_config.nu` (etc.) and accessed via `config --sample` created a great deal of confusion. These were never intended to be used as-is as config files, but rather as in-shell documentation. As such, I've renamed them: * `sample_config.nu` becomes `doc_config.nu` * `sample_env.nu` becomes `doc_env.nu` * `config nu --sample` becomes `config nu --doc` * `config env --sample` because `config env --doc` Also the following: * Updates `doc_config.nu` with a few additional comment-fixes on top of @PerchunPak's changes. * Adds version numbers to all files - Will need to update the version script to add some files after this PR. * Additional doc on plugin and plugin_gc configuration which I had failed to previously completely update from the older wording * Updated the comments in the `scaffold_*.nu` files to point people to `help config`/`help nu` so that, if things change in the future, it will become more difficult for the comments to be outdated. * # User-Facing Changes Mostly doc. `config nu` and `config env` changes update new behavior previously added in 0.100.1 # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting * Update configuration chapter of doc * Update the blog entry on migrating config * Update `bump-version.nu`
This commit is contained in:
22
crates/nu-command/src/env/config/config_env.rs
vendored
22
crates/nu-command/src/env/config/config_env.rs
vendored
@ -18,8 +18,8 @@ impl Command for ConfigEnv {
|
||||
Some('d'),
|
||||
)
|
||||
.switch(
|
||||
"sample",
|
||||
"Print a commented, sample `env.nu` file instead.",
|
||||
"doc",
|
||||
"Print a commented `env.nu` with documentation instead.",
|
||||
Some('s'),
|
||||
)
|
||||
// TODO: Signature narrower than what run actually supports theoretically
|
||||
@ -37,8 +37,8 @@ impl Command for ConfigEnv {
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "pretty-print a commented, sample `env.nu` that explains common settings",
|
||||
example: "config env --sample | nu-highlight,",
|
||||
description: "pretty-print a commented `env.nu` that explains common settings",
|
||||
example: "config env --doc | nu-highlight,",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
@ -57,13 +57,13 @@ impl Command for ConfigEnv {
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let default_flag = call.has_flag(engine_state, stack, "default")?;
|
||||
let sample_flag = call.has_flag(engine_state, stack, "sample")?;
|
||||
if default_flag && sample_flag {
|
||||
let doc_flag = call.has_flag(engine_state, stack, "doc")?;
|
||||
if default_flag && doc_flag {
|
||||
return Err(ShellError::IncompatibleParameters {
|
||||
left_message: "can't use `--default` at the same time".into(),
|
||||
left_span: call.get_flag_span(stack, "default").expect("has flag"),
|
||||
right_message: "because of `--sample`".into(),
|
||||
right_span: call.get_flag_span(stack, "sample").expect("has flag"),
|
||||
right_message: "because of `--doc`".into(),
|
||||
right_span: call.get_flag_span(stack, "doc").expect("has flag"),
|
||||
});
|
||||
}
|
||||
// `--default` flag handling
|
||||
@ -72,10 +72,10 @@ impl Command for ConfigEnv {
|
||||
return Ok(Value::string(nu_utils::get_default_env(), head).into_pipeline_data());
|
||||
}
|
||||
|
||||
// `--sample` flag handling
|
||||
if sample_flag {
|
||||
// `--doc` flag handling
|
||||
if doc_flag {
|
||||
let head = call.head;
|
||||
return Ok(Value::string(nu_utils::get_sample_env(), head).into_pipeline_data());
|
||||
return Ok(Value::string(nu_utils::get_doc_env(), head).into_pipeline_data());
|
||||
}
|
||||
|
||||
super::config_::start_editor("env-path", engine_state, stack, call)
|
||||
|
22
crates/nu-command/src/env/config/config_nu.rs
vendored
22
crates/nu-command/src/env/config/config_nu.rs
vendored
@ -18,8 +18,8 @@ impl Command for ConfigNu {
|
||||
Some('d'),
|
||||
)
|
||||
.switch(
|
||||
"sample",
|
||||
"Print a commented, sample `config.nu` file instead.",
|
||||
"doc",
|
||||
"Print a commented `config.nu` with documentation instead.",
|
||||
Some('s'),
|
||||
)
|
||||
// TODO: Signature narrower than what run actually supports theoretically
|
||||
@ -37,8 +37,8 @@ impl Command for ConfigNu {
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "pretty-print a commented, sample `config.nu` that explains common settings",
|
||||
example: "config nu --sample | nu-highlight",
|
||||
description: "pretty-print a commented `config.nu` that explains common settings",
|
||||
example: "config nu --doc | nu-highlight",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
@ -58,13 +58,13 @@ impl Command for ConfigNu {
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let default_flag = call.has_flag(engine_state, stack, "default")?;
|
||||
let sample_flag = call.has_flag(engine_state, stack, "sample")?;
|
||||
if default_flag && sample_flag {
|
||||
let doc_flag = call.has_flag(engine_state, stack, "doc")?;
|
||||
if default_flag && doc_flag {
|
||||
return Err(ShellError::IncompatibleParameters {
|
||||
left_message: "can't use `--default` at the same time".into(),
|
||||
left_span: call.get_flag_span(stack, "default").expect("has flag"),
|
||||
right_message: "because of `--sample`".into(),
|
||||
right_span: call.get_flag_span(stack, "sample").expect("has flag"),
|
||||
right_message: "because of `--doc`".into(),
|
||||
right_span: call.get_flag_span(stack, "doc").expect("has flag"),
|
||||
});
|
||||
}
|
||||
|
||||
@ -74,10 +74,10 @@ impl Command for ConfigNu {
|
||||
return Ok(Value::string(nu_utils::get_default_config(), head).into_pipeline_data());
|
||||
}
|
||||
|
||||
// `--sample` flag handling
|
||||
if sample_flag {
|
||||
// `--doc` flag handling
|
||||
if doc_flag {
|
||||
let head = call.head;
|
||||
return Ok(Value::string(nu_utils::get_sample_config(), head).into_pipeline_data());
|
||||
return Ok(Value::string(nu_utils::get_doc_config(), head).into_pipeline_data());
|
||||
}
|
||||
|
||||
super::config_::start_editor("config-path", engine_state, stack, call)
|
||||
|
Reference in New Issue
Block a user