Solved variable bug
This commit is contained in:
8
main.py
8
main.py
@@ -242,7 +242,7 @@ For detailed help on each command, use:
|
||||
if selected:
|
||||
show_config(selected, USER_CONFIG_PATH, full_config=False)
|
||||
elif args.subcommand == "add":
|
||||
interactive_add(config_merged)
|
||||
interactive_add(config_merged,USER_CONFIG_PATH)
|
||||
elif args.subcommand == "edit":
|
||||
"""Open the user configuration file in nano."""
|
||||
run_command(f"nano {USER_CONFIG_PATH}")
|
||||
@@ -252,7 +252,7 @@ For detailed help on each command, use:
|
||||
user_config = yaml.safe_load(f) or {}
|
||||
else:
|
||||
user_config = {"repositories": []}
|
||||
config_init(user_config, config_merged, BIN_DIR)
|
||||
config_init(user_config, config_merged, BIN_DIR, USER_CONFIG_PATH)
|
||||
elif args.subcommand == "delete":
|
||||
# Load user config from USER_CONFIG_PATH.
|
||||
if os.path.exists(USER_CONFIG_PATH):
|
||||
@@ -266,7 +266,7 @@ For detailed help on each command, use:
|
||||
to_delete = resolve_repos(args.identifiers, user_config.get("repositories", []))
|
||||
new_repos = [entry for entry in user_config.get("repositories", []) if entry not in to_delete]
|
||||
user_config["repositories"] = new_repos
|
||||
save_user_config(user_config)
|
||||
save_user_config(user_config,USER_CONFIG_PATH)
|
||||
print(f"Deleted {len(to_delete)} entries from user config.")
|
||||
elif args.subcommand == "ignore":
|
||||
# Load user config from USER_CONFIG_PATH.
|
||||
@@ -286,6 +286,6 @@ For detailed help on each command, use:
|
||||
if key == mod_key:
|
||||
entry["ignore"] = (args.set == "true")
|
||||
print(f"Set ignore for {key} to {entry['ignore']}")
|
||||
save_user_config(user_config)
|
||||
save_user_config(user_config,USER_CONFIG_PATH)
|
||||
else:
|
||||
parser.print_help()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
def config_init(user_config, defaults_config, bin_dir):
|
||||
def config_init(user_config, defaults_config, bin_dir,USER_CONFIG_PATH:str):
|
||||
"""
|
||||
Scan the base directory (defaults_config["base"]) for repositories.
|
||||
The folder structure is assumed to be:
|
||||
@@ -68,6 +68,6 @@ def config_init(user_config, defaults_config, bin_dir):
|
||||
|
||||
if new_entries:
|
||||
user_config.setdefault("repositories", []).extend(new_entries)
|
||||
save_user_config(user_config)
|
||||
save_user_config(user_config,USER_CONFIG_PATH)
|
||||
else:
|
||||
print("No new repositories found.")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import yaml
|
||||
import os
|
||||
|
||||
def interactive_add(config):
|
||||
def interactive_add(config,USER_CONFIG_PATH:str):
|
||||
"""Interactively prompt the user to add a new repository entry to the user config."""
|
||||
print("Adding a new repository configuration entry.")
|
||||
new_entry = {}
|
||||
@@ -33,6 +33,6 @@ def interactive_add(config):
|
||||
user_config = {"repositories": []}
|
||||
user_config.setdefault("repositories", [])
|
||||
user_config["repositories"].append(new_entry)
|
||||
save_user_config(user_config)
|
||||
save_user_config(user_config,USER_CONFIG_PATH)
|
||||
else:
|
||||
print("Entry not added.")
|
||||
@@ -1,7 +1,7 @@
|
||||
import yaml
|
||||
import os
|
||||
|
||||
def save_user_config(user_config):
|
||||
def save_user_config(user_config,USER_CONFIG_PATH:str):
|
||||
"""Save the user configuration to USER_CONFIG_PATH."""
|
||||
os.makedirs(os.path.dirname(USER_CONFIG_PATH), exist_ok=True)
|
||||
with open(USER_CONFIG_PATH, 'w') as f:
|
||||
|
||||
Reference in New Issue
Block a user