More completion work

This commit is contained in:
Kovid Goyal
2022-11-14 15:41:58 +05:30
parent 946d44c43f
commit 0ff2446a1a
7 changed files with 46 additions and 5 deletions
+8
View File
@@ -68,6 +68,7 @@ type Command struct {
Completion_for_arg completion_func
Stop_processing_at_arg int
First_arg_may_not_be_subcommand bool
Subcommand_must_be_first bool
}
func (self *Command) add_group(name string) *CommandGroup {
@@ -122,6 +123,13 @@ func (self *Command) has_subcommands() bool {
return false
}
func (self *Command) sub_command_allowed_at(completions *Completions, arg_num int) bool {
if self.Subcommand_must_be_first {
return arg_num == 1 && completions.current_word_idx == 0
}
return arg_num == 1
}
func (self *Command) add_option(opt *Option) {
self.Options = append(self.Options, opt)
}