From 49f282ba1d7e25acda8f2c533b10ce2a4c648da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 30 Aug 2023 16:47:40 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Improve=20UX=20of=20systeminfo?= =?UTF-8?q?=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `octoprint systeminfo` will now generate a bundle in the current directory even without an explicitly added . - `octoprint systeminfo --short` has been added to generate the abridged version This should clear up issues we saw in the past where users forgot the . and then just pasted the abridged text only version when we wanted a bundle. --- src/octoprint/cli/systeminfo.py | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/octoprint/cli/systeminfo.py b/src/octoprint/cli/systeminfo.py index c00e132f7..edbd78a1a 100644 --- a/src/octoprint/cli/systeminfo.py +++ b/src/octoprint/cli/systeminfo.py @@ -167,6 +167,11 @@ def cli(): @cli.command(name="systeminfo") @standard_options() +@click.option( + "--short", + is_flag=True, + help="Only output an abridged version of the systeminfo.", +) @click.argument( "path", nargs=1, @@ -174,8 +179,16 @@ def cli(): type=click.Path(writable=True, dir_okay=True, resolve_path=True), ) @click.pass_context -def systeminfo_command(ctx, path, **kwargs): - """Retrieves and prints the system info.""" +def systeminfo_command(ctx, short, path, **kwargs): + """ + Creates a system info bundle at PATH. + + If PATH is not provided, the system info bundle will be created in the + current working directory. + + If --short is provided, only an abridged version of the systeminfo will be + output to the console. + """ logging.disable(logging.ERROR) try: ( @@ -199,9 +212,19 @@ def systeminfo_command(ctx, path, **kwargs): additional_fields={"systeminfo.generator": "cli"}, ) - if path: + if short: + # output abridged systeminfo to console + for k in sorted(systeminfo.keys()): + click.echo(f"{k}: {systeminfo[k]}") + + else: + if not path: + path = "." + # create zip at path - zipfilename = os.path.join(path, get_systeminfo_bundle_name()) + zipfilename = os.path.abspath( + os.path.join(path, get_systeminfo_bundle_name()) + ) click.echo(f"Writing systeminfo bundle to {zipfilename}...") z = get_systeminfo_bundle( @@ -218,8 +241,4 @@ def systeminfo_command(ctx, path, **kwargs): click.echo("Done!") click.echo(zipfilename) - else: - # output systeminfo to console - for k in sorted(systeminfo.keys()): - click.echo(f"{k}: {systeminfo[k]}") ctx.exit(0)