- Replace hardcoded CONFIG_PATH with appdirs AppDirs (use app.user_config_dir) and update SETTINGS_PATH - Rework dataclasses: add Library, QbitTorrent; convert Komga.libraries to List[Library]; use Path for media_path; add getLibraryByName and proper __post_init__ conversions - Extend KomGrabber to support downloader/downloader_settings (aria2/qbit), normalize Path handling and expanduser usage - Add type fixes, utility methods (getattr/_setattr) and API __post_init__ to convert nested dicts to dataclass instances - Add package CLI entrypoints (__main__.py, src package main) and simple runner (main.py) - Add tests for package __init__ CLI and config behavior (tests/*) and a small test script (test.py) - Add .vscode/settings.json for pytest integration - Tidy pyproject.toml: format dependencies, add dev/test dependency groups and fix trailing newline in bumpversion section
31 lines
892 B
Python
31 lines
892 B
Python
import argparse
|
|
from src.komconfig import KomConfig
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Retrieve configuration values.")
|
|
parser.add_argument("key", type=str, help="The configuration key to retrieve.")
|
|
args = parser.parse_args()
|
|
|
|
config = KomConfig()
|
|
|
|
try:
|
|
config_dict = config.dict()
|
|
if isinstance(config_dict, dict):
|
|
value = config_dict.get(args.key, None)
|
|
if value is None:
|
|
print(f"Key '{args.key}' not found in the configuration.")
|
|
else:
|
|
try:
|
|
print(str(value))
|
|
except Exception:
|
|
print(repr(value))
|
|
else:
|
|
print("Configuration data is not in dictionary format.")
|
|
except Exception as e:
|
|
print(f"Error retrieving key '{args.key}': {e}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|