mirror of
https://github.com/nushell/nushell
synced 2025-01-14 14:14:13 +00:00
Add meta command for the config subcommands (#5616)
When using `config` without the `config nu` or `config env` subcommands introduced by #5607 display basic usage like `str`.
This commit is contained in:
parent
d534a89867
commit
6ff717c0ba
4 changed files with 50 additions and 0 deletions
|
@ -317,6 +317,7 @@ pub fn create_default_context(cwd: impl AsRef<Path>) -> EngineState {
|
|||
WithEnv,
|
||||
ConfigNu,
|
||||
ConfigEnv,
|
||||
ConfigMeta,
|
||||
};
|
||||
|
||||
// Math
|
||||
|
|
46
crates/nu-command/src/env/config/config_.rs
vendored
Normal file
46
crates/nu-command/src/env/config/config_.rs
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
use nu_engine::get_full_help;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, IntoPipelineData, PipelineData, Signature, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ConfigMeta;
|
||||
|
||||
impl Command for ConfigMeta {
|
||||
fn name(&self) -> &str {
|
||||
"config"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Env)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Edit nushell configuration files"
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
stack: &mut Stack,
|
||||
call: &Call,
|
||||
_input: PipelineData,
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
Ok(Value::String {
|
||||
val: get_full_help(
|
||||
&ConfigMeta.signature(),
|
||||
&ConfigMeta.examples(),
|
||||
engine_state,
|
||||
stack,
|
||||
),
|
||||
span: call.head,
|
||||
}
|
||||
.into_pipeline_data())
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["options", "setup"]
|
||||
}
|
||||
}
|
2
crates/nu-command/src/env/config/mod.rs
vendored
2
crates/nu-command/src/env/config/mod.rs
vendored
|
@ -1,5 +1,7 @@
|
|||
mod config_;
|
||||
mod config_env;
|
||||
mod config_nu;
|
||||
mod utils;
|
||||
pub use config_::ConfigMeta;
|
||||
pub use config_env::ConfigEnv;
|
||||
pub use config_nu::ConfigNu;
|
||||
|
|
1
crates/nu-command/src/env/mod.rs
vendored
1
crates/nu-command/src/env/mod.rs
vendored
|
@ -5,6 +5,7 @@ mod load_env;
|
|||
mod with_env;
|
||||
|
||||
pub use config::ConfigEnv;
|
||||
pub use config::ConfigMeta;
|
||||
pub use config::ConfigNu;
|
||||
pub use env_command::Env;
|
||||
pub use let_env::LetEnv;
|
||||
|
|
Loading…
Reference in a new issue