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
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
6 changed files with 54 additions and 64 deletions

View file

@ -10,7 +10,7 @@ import (
var _ = fmt.Print
func (self *Command) parse_args(ctx *Context, args []string) error {
args_to_parse := make([]string, 0, len(args))
args_to_parse := make([]string, len(args))
copy(args_to_parse, args)
ctx.SeenCommands = append(ctx.SeenCommands, self)
@ -39,7 +39,7 @@ func (self *Command) parse_args(ctx *Context, args []string) error {
return nil
}
for len(self.Args) > 0 {
for len(args_to_parse) > 0 {
arg := consume_arg()
if expecting_arg_for == nil {
@ -49,10 +49,10 @@ func (self *Command) parse_args(ctx *Context, args []string) error {
options_allowed = false
continue
}
opt_str := ""
opt_str := arg
opt_val := ""
has_val := false
if strings.HasPrefix(opt_str, "--") || len(opt_str) == 2 {
if strings.HasPrefix(opt_str, "--") {
parts := strings.SplitN(arg, "=", 2)
if len(parts) > 1 {
has_val = true