From 14c1dfe9a3989fb5a282048986b60a0c7e00a593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 10 Nov 2017 19:08:24 +0100 Subject: [PATCH] New command "octoprint config effective" --- src/octoprint/cli/config.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/octoprint/cli/config.py b/src/octoprint/cli/config.py index 3554a14d..744cfee4 100644 --- a/src/octoprint/cli/config.py +++ b/src/octoprint/cli/config.py @@ -214,3 +214,28 @@ def get_command(ctx, path, as_json=False, as_yaml=False, as_raw=False): output = pprint.pformat(value) click.echo(output) + + +@config.command(name="effective") +@click.option("--json", "as_json", is_flag=True, + help="Output value formatted as JSON") +@click.option("--yaml", "as_yaml", is_flag=True, + help="Output value formatted as YAML") +@click.option("--raw", "as_raw", is_flag=True, + help="Output value as raw string representation") +@standard_options(hidden=True) +@click.pass_context +def effective_command(ctx, as_json=False, as_yaml=False, as_raw=False): + """Retrieves the full effective config.""" + value = ctx.obj.settings.effective + + if as_json: + output = json.dumps(value) + elif as_yaml: + output = yaml.safe_dump(value, default_flow_style=False, indent=" ", allow_unicode=True) + elif as_raw: + output = value + else: + output = pprint.pformat(value) + + click.echo(output)