From 1fd8acdee4237f280341e1442917c0bfa12c90d4 Mon Sep 17 00:00:00 2001 From: derrod Date: Tue, 28 Dec 2021 14:20:44 +0100 Subject: [PATCH] [cli] Use argparse choices instead of manual check --- legendary/cli.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/legendary/cli.py b/legendary/cli.py index 207a19d..8ac9741 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -1679,10 +1679,6 @@ class LegendaryCLI: return self._print_json(json_out, args.pretty_json) 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': alias = args.alias app_name = self._resolve_aliases(args.app_or_alias) @@ -1975,6 +1971,7 @@ def main(): metavar='') alias_parser.add_argument('action', help='Action: Add, rename, remove, or list alias(es)', + choices=['add', 'rename', 'remove', 'list'], metavar='') alias_parser.add_argument('app_or_alias', help='App name when using "add" or "list" action, ' 'existing alias when using "rename" or "remove" action',