Skip to content

Commit

Permalink
fix: clean up double_dash rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 18, 2024
1 parent 8ad1ddd commit eac7db8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/src/spec/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl From<&SpecArg> for KdlNode {
if !arg.required {
node.push(KdlEntry::new_prop("required", false));
}
if arg.double_dash != SpecDoubleDashChoices::Optional {
if arg.double_dash == SpecDoubleDashChoices::Automatic {
node.push(KdlEntry::new_prop(
"double_dash",
arg.double_dash.to_string(),
Expand Down Expand Up @@ -158,9 +158,9 @@ impl From<&str> for SpecArg {
required: true,
..Default::default()
};
if input.strip_suffix("...").is_some() {
if let Some(name) = arg.name.strip_suffix("...") {
arg.var = true;
arg.name = arg.name[..arg.name.len() - 3].to_string();
arg.name = name.to_string();
}
let first = arg.name.chars().next().unwrap_or_default();
let last = arg.name.chars().last().unwrap_or_default();
Expand All @@ -174,7 +174,10 @@ impl From<&str> for SpecArg {
}
_ => {}
}
// TODO: handle doubledash choice
if let Some(name) = arg.name.strip_prefix("-- ") {
arg.double_dash = SpecDoubleDashChoices::Required;
arg.name = name.to_string();
}
arg
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/tests/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ tests_same! {
arg_choices: r#"arg "<shell>" {
choices "bash" "fish" "zsh"
}"#,

double_dash: r#"arg "<-- shell...>""#,
}

0 comments on commit eac7db8

Please sign in to comment.