feat(cli): add option to disable user config

This commit is contained in:
benexl
2025-01-04 23:37:30 +03:00
parent 1d40160abf
commit 2f5684a93a
2 changed files with 7 additions and 5 deletions

View File

@@ -184,6 +184,7 @@ signal.signal(signal.SIGINT, handle_exit)
@click.option(
"--fresh-requests", is_flag=True, help="Force the requests cache to be updated"
)
@click.option("--no-config", is_flag=True, help="Don't load the user config")
@click.pass_context
def run_cli(
ctx: click.Context,
@@ -220,13 +221,14 @@ def run_cli(
sync_play,
player,
fresh_requests,
no_config,
):
import os
import sys
from .config import Config
ctx.obj = Config()
ctx.obj = Config(no_config)
if (
ctx.obj.check_for_updates
and ctx.invoked_subcommand != "completions"

View File

@@ -84,18 +84,18 @@ class Config(object):
"use_rofi": "false",
}
def __init__(self) -> None:
def __init__(self, no_config) -> None:
self.initialize_user_data_and_watch_history_recent_anime()
self.load_config()
self.load_config(no_config)
def load_config(self):
def load_config(self, no_config=False):
self.configparser = ConfigParser(self.default_config)
self.configparser.add_section("stream")
self.configparser.add_section("general")
self.configparser.add_section("anilist")
# --- set config values from file or using defaults ---
if os.path.exists(USER_CONFIG_PATH):
if os.path.exists(USER_CONFIG_PATH) and not no_config:
self.configparser.read(USER_CONFIG_PATH, encoding="utf-8")
# get the configuration