From fd0b12d310eeef46516b2c347f4b3243f5dae7ee Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 6 Dec 2015 15:58:02 +0000 Subject: [PATCH] View all config --- project/config/cli.py | 6 +++++- project/utils/config.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/project/config/cli.py b/project/config/cli.py index bb4be23..44bf1e9 100644 --- a/project/config/cli.py +++ b/project/config/cli.py @@ -11,7 +11,11 @@ def cli(): @click.argument('key', nargs=-1) def show(key): key = " ".join(key) - print(config.get(key)) + if not key: + for key, value in config.get_all().items(): + print("{}: {}".format(key, value)) + return 0 + print("'{}' is set to '{}'".format(key, config.get(key))) return 0 diff --git a/project/utils/config.py b/project/utils/config.py index ba7d0f0..4ab6aef 100644 --- a/project/utils/config.py +++ b/project/utils/config.py @@ -45,6 +45,13 @@ def get(key): return None +def get_all(): + all_config = {} + for key, value in DEFAULT_CONFIG.items(): + all_config[key] = get(key) + return all_config + + def set(key, value): if key not in DEFAULT_CONFIG: return "NO_KEY"