From 61f9bfabdba7a19aff532c062b8dcd94705f1b37 Mon Sep 17 00:00:00 2001 From: Patrick Marsee Date: Mon, 30 Jan 2023 23:11:27 -0500 Subject: [PATCH] CLI: list command prints in alphabetical order. Profiles can be deleted. --- seven_mods.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/seven_mods.py b/seven_mods.py index 81309b0..66c4d4f 100755 --- a/seven_mods.py +++ b/seven_mods.py @@ -227,7 +227,7 @@ def get_loaded_mods(cfg: Config) -> list: if entry.is_symlink() and entry.is_dir(): # only ret.append(entry.name) - return ret + return sorted(ret, key = lambda x: x.casefold()) def get_available_mods(cfg: Config) -> list: ret = [] @@ -235,7 +235,7 @@ def get_available_mods(cfg: Config) -> list: for entry in it: if entry.is_dir() and entry.name != "__pycache__": ret.append(entry.name) - return ret + return sorted(ret, key = lambda x: x.casefold()) def enable_mod(cfg: Config, mod_name: str): link_source = os.path.join(cfg.mods_dir, mod_name) @@ -320,6 +320,17 @@ def command_load(args: list, cfg: Config, profiles: ModProfiles): else: print(f"Usage: {args[0]} {args[1]} ") +def command_delete(args: list, cfg: Config, profiles: ModProfiles): + if len(args) > 2: + for prof in args[2:]: + if prof in profiles.profiles: + del profiles.profiles[prof] + profiles.save_mod_profiles() + else: + print(f"Cannot delete non-existant profile: {prof}") + else: + print(f"Usage: {args[0]} {args[1]} ") + def command_configure(args: list, cfg: Config, profiles: ModProfiles): prompt_configuration_cli() @@ -335,6 +346,7 @@ def parse_input(args: list, cfg: Config, profiles: ModProfiles): "toggle" : command_toggle, "save" : command_save, "load" : command_load, + "delete" : command_delete, "config" : command_configure, "help" : command_help, "--help" : command_help}