[cli] Use argparse choices instead of manual check

This commit is contained in:
derrod 2021-12-28 14:20:44 +01:00
parent 599e4766b2
commit 1fd8acdee4

View file

@ -1679,10 +1679,6 @@ class LegendaryCLI:
return self._print_json(json_out, args.pretty_json) return self._print_json(json_out, args.pretty_json)
def alias(self, args): def alias(self, args):
if args.action not in ('add', 'rename', 'remove', 'list'):
logger.error(f'Invalid action "{args.action}"!')
return
if args.action == 'add': if args.action == 'add':
alias = args.alias alias = args.alias
app_name = self._resolve_aliases(args.app_or_alias) app_name = self._resolve_aliases(args.app_or_alias)
@ -1975,6 +1971,7 @@ def main():
metavar='<App Name/Manifest URI>') metavar='<App Name/Manifest URI>')
alias_parser.add_argument('action', help='Action: Add, rename, remove, or list alias(es)', alias_parser.add_argument('action', help='Action: Add, rename, remove, or list alias(es)',
choices=['add', 'rename', 'remove', 'list'],
metavar='<add|rename|remove|list>') metavar='<add|rename|remove|list>')
alias_parser.add_argument('app_or_alias', help='App name when using "add" or "list" action, ' alias_parser.add_argument('app_or_alias', help='App name when using "add" or "list" action, '
'existing alias when using "rename" or "remove" action', 'existing alias when using "rename" or "remove" action',