Create hidden alias commands so kitty-tool @ls also works

This commit is contained in:
Kovid Goyal 2022-08-17 00:11:28 +05:30
parent d3bb69a0ac
commit bab914c497
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 1 deletions

View File

@ -17,7 +17,7 @@ def serialize_as_go_string(x: str) -> str:
def build_go_code(name: str, cmd: RemoteCommand, opts: Any, template: str) -> str: def build_go_code(name: str, cmd: RemoteCommand, opts: Any, template: str) -> str:
template = template[len('//go:build exclude'):] template = '\n' + template[len('//go:build exclude'):]
ans = template.replace('CMD_NAME', name).replace('__FILE__', __file__).replace('CLI_NAME', name.replace('_', '-')).replace( ans = template.replace('CMD_NAME', name).replace('__FILE__', __file__).replace('CLI_NAME', name.replace('_', '-')).replace(
'SHORT_DESC', serialize_as_go_string(cmd.short_desc)).replace('LONG_DESC', serialize_as_go_string(cmd.desc.strip())) 'SHORT_DESC', serialize_as_go_string(cmd.short_desc)).replace('LONG_DESC', serialize_as_go_string(cmd.desc.strip()))
return ans return ans

View File

@ -121,6 +121,10 @@ func EntryPoint(tool_root *cobra.Command) *cobra.Command {
c := reg_func(at_root_command) c := reg_func(at_root_command)
at_root_command.AddCommand(c) at_root_command.AddCommand(c)
command_objects[cmd_name] = c command_objects[cmd_name] = c
alias := *c
alias.Use = "@" + alias.Use
alias.Hidden = true
tool_root.AddCommand(&alias)
} }
return at_root_command return at_root_command
} }