From 5fd02b20f56dc4780dc420b74ade665695089346 Mon Sep 17 00:00:00 2001 From: ysthakur <45539777+ysthakur@users.noreply.github.com> Date: Sun, 14 Jan 2024 14:31:46 -0500 Subject: [PATCH] Don't require hyphen as node name in kdl flags --- Cargo.toml | 3 +-- src/gen/kdl.rs | 11 +++++------ src/main.rs | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 083153f..f484b79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ clap = { version = "4.3", features = ["derive", "env"] } env_logger = "0.10" indoc = "2" log = "0.4" -miette = "5.10" +miette = { version = "5.10", features = ["fancy"] } regex = "1.9" thiserror = "1.0" @@ -37,7 +37,6 @@ serde_yaml = "0.9" [dev-dependencies] assert_cmd = "2.0" insta = "1" -miette = { version = "5.10", features = ["fancy"] } pretty_assertions = "1" tempfile = "3" diff --git a/src/gen/kdl.rs b/src/gen/kdl.rs index 8ebd6fc..6d51da9 100644 --- a/src/gen/kdl.rs +++ b/src/gen/kdl.rs @@ -10,19 +10,18 @@ pub fn to_kdl_node(cmd: &CommandInfo) -> KdlNode { let mut flag_nodes = KdlDocument::new(); for flag in &cmd.flags { - let mut flag_node = KdlNode::new("-"); + let mut form_iter = flag.forms.iter(); + let mut flag_node = KdlNode::new(form_iter.next().unwrap().as_str()); - for form in &flag.forms { - flag_node - .entries_mut() - .push(KdlEntry::new(form.to_string())); + for form in form_iter { + flag_node.entries_mut().push(KdlEntry::new(form.as_str())); } if let Some(desc) = &flag.desc { let mut description_node = KdlNode::new("desc"); description_node .entries_mut() - .push(KdlEntry::new(desc.to_string())); + .push(KdlEntry::new(desc.as_str())); let mut flag_children = KdlDocument::new(); flag_children.nodes_mut().push(description_node); diff --git a/src/main.rs b/src/main.rs index 3bd3bf8..8ef0cd3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,7 +65,7 @@ enum Commands { /// File to generate completions from conf: PathBuf, - /// File to generate completions to. Outputted to stdout if not given. + /// Folder to generate completions to. Outputted to stdout if not given. out: Option, }, }