Move kitty-tool __complete__ to use the new CLI framework

This commit is contained in:
Kovid Goyal
2022-09-23 12:30:41 +05:30
parent e7c14c78d0
commit 79cfc1e70a
6 changed files with 54 additions and 64 deletions

View File

@@ -107,7 +107,7 @@ func option_from_spec(spec OptionSpec) (*Option, error) {
}
parts := strings.Split(spec.Name, " ")
ans.Name = camel_case_dest(parts[0])
ans.Aliases = make([]Alias, 0, len(parts))
ans.Aliases = make([]Alias, len(parts))
for i, x := range parts {
ans.Aliases[i] = Alias{NameWithoutHyphens: strings.TrimLeft(x, "-"), IsShort: !strings.HasPrefix(x, "--")}
}
@@ -198,7 +198,7 @@ func prepare_help_text_for_display(raw string) string {
}
}
prev_indent = current_indent
if !strings.HasSuffix(help.String(), "\n") {
if help.Len() > 0 && !strings.HasSuffix(help.String(), "\n") {
help.WriteString(" ")
}
help.WriteString(line)