added short aliases for subcommands
This commit is contained in:
parent
e8eba0b755
commit
a5075b14a0
@ -163,7 +163,8 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
|
||||
# 'ask' command parser
|
||||
ask_cmd_parser = cmdparser.add_parser('ask', parents=[tag_parser],
|
||||
help="Ask a question.")
|
||||
help="Ask a question.",
|
||||
aliases=['a'])
|
||||
ask_cmd_parser.set_defaults(func=ask_cmd)
|
||||
ask_cmd_parser.add_argument('-q', '--question', nargs='+', help='Question to ask',
|
||||
required=True)
|
||||
@ -178,7 +179,8 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
|
||||
# 'hist' command parser
|
||||
hist_cmd_parser = cmdparser.add_parser('hist', parents=[tag_parser],
|
||||
help="Print chat history.")
|
||||
help="Print chat history.",
|
||||
aliases=['h'])
|
||||
hist_cmd_parser.set_defaults(func=hist_cmd)
|
||||
hist_cmd_parser.add_argument('-d', '--dump', help="Print chat history as Python structure",
|
||||
action='store_true')
|
||||
@ -191,14 +193,17 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
|
||||
# 'tag' command parser
|
||||
tag_cmd_parser = cmdparser.add_parser('tag',
|
||||
help="Manage tags.")
|
||||
help="Manage tags.",
|
||||
aliases=['t'])
|
||||
tag_cmd_parser.set_defaults(func=tag_cmd)
|
||||
tag_cmd_parser.add_argument('-l', '--list', help="List all tags and their frequency",
|
||||
action='store_true')
|
||||
tag_group = tag_cmd_parser.add_mutually_exclusive_group(required=True)
|
||||
tag_group.add_argument('-l', '--list', help="List all tags and their frequency",
|
||||
action='store_true')
|
||||
|
||||
# 'config' command parser
|
||||
config_cmd_parser = cmdparser.add_parser('config',
|
||||
help="Manage configuration")
|
||||
help="Manage configuration",
|
||||
aliases=['c'])
|
||||
config_cmd_parser.set_defaults(func=config_cmd)
|
||||
config_group = config_cmd_parser.add_mutually_exclusive_group(required=True)
|
||||
config_group.add_argument('-l', '--list-models', help="List all available models",
|
||||
@ -209,7 +214,8 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
|
||||
# 'print' command parser
|
||||
print_cmd_parser = cmdparser.add_parser('print',
|
||||
help="Print files.")
|
||||
help="Print files.",
|
||||
aliases=['p'])
|
||||
print_cmd_parser.set_defaults(func=print_cmd)
|
||||
print_cmd_parser.add_argument('-f', '--file', help='File to print', required=True)
|
||||
print_cmd_parser.add_argument('-S', '--only-source-code', help='Print only source code',
|
||||
|
||||
@ -219,9 +219,9 @@ class TestCreateParser(unittest.TestCase):
|
||||
parser = create_parser()
|
||||
self.assertIsInstance(parser, argparse.ArgumentParser)
|
||||
mock_add_subparsers.assert_called_once_with(dest='command', title='commands', description='supported commands', required=True)
|
||||
mock_cmdparser.add_parser.assert_any_call('ask', parents=ANY, help=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('hist', parents=ANY, help=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('tag', help=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('config', help=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('print', help=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('ask', parents=ANY, help=ANY, aliases=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('hist', parents=ANY, help=ANY, aliases=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('tag', help=ANY, aliases=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('config', help=ANY, aliases=ANY)
|
||||
mock_cmdparser.add_parser.assert_any_call('print', help=ANY, aliases=ANY)
|
||||
self.assertTrue('.config.yaml' in parser.get_default('config'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user