Split key/value in 'config set' (#2151)

This commit is contained in:
Jonathan Turner 2020-07-10 18:15:51 -07:00 committed by GitHub
parent e848fc0bbe
commit 1bb6a2d9ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,8 @@ pub struct SubCommand;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct SetArgs { pub struct SetArgs {
set: (Tagged<String>, Value), key: Tagged<String>,
value: Value,
} }
#[async_trait] #[async_trait]
@ -19,11 +20,9 @@ impl WholeStreamCommand for SubCommand {
} }
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("config set").required( Signature::build("config set")
"set", .required("key", SyntaxShape::String, "variable name to set")
SyntaxShape::Any, .required("value", SyntaxShape::Any, "value to use")
"sets a value in the config, eg) set [key value]",
)
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -52,7 +51,7 @@ pub async fn set(
registry: &CommandRegistry, registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> { ) -> Result<OutputStream, ShellError> {
let name_span = args.call_info.name_tag.clone(); let name_span = args.call_info.name_tag.clone();
let (SetArgs { set: (key, value) }, _) = args.process(&registry).await?; let (SetArgs { key, value }, _) = args.process(&registry).await?;
// NOTE: None because we are not loading a new config file, we just want to read from the // NOTE: None because we are not loading a new config file, we just want to read from the
// existing config // existing config