Make adding subcommands a bit nicer

This commit is contained in:
Kovid Goyal
2022-09-25 12:39:42 +05:30
parent 4396dede85
commit 5771bd0c01
5 changed files with 42 additions and 27 deletions

View File

@@ -311,10 +311,12 @@ func setup_global_options(cmd *cli.Command) (err error) {
}
func EntryPoint(tool_root *cli.Command) *cli.Command {
at_root_command := tool_root.AddSubCommand("", "@")
at_root_command.Usage = "[global options] [sub-command] [sub-command options] [sub-command args]"
at_root_command.ShortDescription = "Control kitty remotely"
at_root_command.HelpText = "Control kitty by sending it commands. Set the allow_remote_control option in :file:`kitty.conf` for this to work. When run without any sub-commands this will start an interactive shell to control kitty."
at_root_command := tool_root.AddSubCommand(&cli.Command{
Name: "@",
Usage: "[global options] [sub-command] [sub-command options] [sub-command args]",
ShortDescription: "Control kitty remotely",
HelpText: "Control kitty by sending it commands. Set the allow_remote_control option in :file:`kitty.conf` for this to work. When run without any sub-commands this will start an interactive shell to control kitty.",
})
add_rc_global_opts(at_root_command)
global_options_group := at_root_command.OptionGroups[0]

View File

@@ -94,11 +94,13 @@ func run_CMD_NAME(cmd *cli.Command, args []string) (return_code int, err error)
}
func setup_CMD_NAME(parent *cli.Command) *cli.Command {
ans := parent.AddSubCommand("", "CMD_NAME")
ans.Usage = "ARGSPEC"
ans.ShortDescription = "SHORT_DESC"
ans.HelpText = "LONG_DESC"
ans.Run = run_CMD_NAME
ans := parent.AddSubCommand(&cli.Command{
Name: "CMD_NAME",
Usage: "ARGSPEC",
ShortDescription: "SHORT_DESC",
HelpText: "LONG_DESC",
Run: run_CMD_NAME,
})
ADD_FLAGS_CODE
return ans
}