From cfb490601f2d7045499d3556201992765db13ce4 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Mon, 11 Nov 2024 16:04:29 +0100 Subject: Hardcode default commands We really don't need to influence these dynamically, so simplify the code a bit by hardcoding the default "list" and "add" commands in parse_args(). --- src/later/cli.py | 6 +++--- src/later/main.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/later/cli.py b/src/later/cli.py index 809632f..ece41ce 100644 --- a/src/later/cli.py +++ b/src/later/cli.py @@ -54,7 +54,7 @@ def list_entries(args, entries): entries.print() -def parse_args(argv, default, default_args): +def parse_args(argv): commands = { "add": Command("add", add_entries), "del": Command("del", delete_entries), @@ -66,7 +66,7 @@ def parse_args(argv, default, default_args): except getopt.GetoptError as e: usage(e) - parsed_args = Arguments(command=commands[default]) + parsed_args = Arguments(command=commands["list"]) for option in options: match option: @@ -77,7 +77,7 @@ def parse_args(argv, default, default_args): if args[0] in commands: parsed_args.command = commands[args.pop(0)] else: - parsed_args.command = commands[default_args] + parsed_args.command = commands["add"] parsed_args.rest = args diff --git a/src/later/main.py b/src/later/main.py index 1d07cac..6bf2426 100644 --- a/src/later/main.py +++ b/src/later/main.py @@ -17,7 +17,7 @@ title_map_file = os.path.join(later_cache_dir, "titles.json") def main(): - args = parse_args(sys.argv[1:], "list", "add") + args = parse_args(sys.argv[1:]) title_map = TitleMap(title_map_file, update=args.update_titles) entries = EntryManager(watch_later_dir, title_map) -- cgit v1.2.3-2-gb3c3