From 5d190aee5ddd0751d16bfb0a30a12f8bd9a0ef36 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 18 May 2023 09:39:42 -0300 Subject: [PATCH] [CLI][Added] `--output-name-first` to list outputs by name - No description See #436 --- CHANGELOG.md | 1 + README.md | 3 ++- kibot/__main__.py | 16 +++++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e5f4504..efb1d8b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `--only-names` to make `--list` list only output names - `--only-pre` to list only the preflights - `--only-groups` to list only the groups + - `--output-name-first` to list outputs by name, no description (See #436) - Global options: - `use_os_env_for_expand` to disable OS environment expansion - `environment`.`extra_os` to define environment variables diff --git a/README.md b/README.md index 63fbf7b0..a4e90a07 100644 --- a/README.md +++ b/README.md @@ -5672,7 +5672,7 @@ Usage: [-E DEF] ... [-w LIST] [--banner N] [TARGET...] kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] [--banner N] [-E DEF] ... [--config-outs] [--only-pre|--only-groups] [--only-names] - --list + [--output-name-first] --list kibot [-v...] [-c PLOT_CONFIG] [--banner N] [-E DEF] ... [--only-names] --list-variants kibot [-v...] [-b BOARD] [-d OUT_DIR] [-p | -P] [--banner N] --example @@ -5721,6 +5721,7 @@ Options: also acts as a virtual --only-outputs --only-groups Print only the groups. --only-pre Print only the preflights + --output-name-first Use the output name first when listing -P, --copy-and-expand As -p but expand the list of layers -q, --quiet Remove information logs -s PRE, --skip-pre PRE Skip preflights, comma separated or `all` diff --git a/kibot/__main__.py b/kibot/__main__.py index 782bb002..fae8f7f3 100644 --- a/kibot/__main__.py +++ b/kibot/__main__.py @@ -13,7 +13,7 @@ Usage: [-E DEF] ... [-w LIST] [--banner N] [TARGET...] kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] [--banner N] [-E DEF] ... [--config-outs] [--only-pre|--only-groups] [--only-names] - --list + [--output-name-first] --list kibot [-v...] [-c PLOT_CONFIG] [--banner N] [-E DEF] ... [--only-names] --list-variants kibot [-v...] [-b BOARD] [-d OUT_DIR] [-p | -P] [--banner N] --example @@ -62,6 +62,7 @@ Options: also acts as a virtual --only-outputs --only-groups Print only the groups. --only-pre Print only the preflights + --output-name-first Use the output name first when listing -P, --copy-and-expand As -p but expand the list of layers -q, --quiet Remove information logs -s PRE, --skip-pre PRE Skip preflights, comma separated or `all` @@ -148,7 +149,7 @@ def list_pre_and_outs_names(logger, outputs, do_config, only_pre, only_groups): logger.info(o.name) -def list_pre_and_outs(logger, outputs, do_config, only_names, only_pre, only_groups): +def list_pre_and_outs(logger, outputs, do_config, only_names, only_pre, only_groups, output_name_first): if only_names: return list_pre_and_outs_names(logger, outputs, do_config, only_pre, only_groups) pf = BasePreFlight.get_in_use_objs() @@ -159,13 +160,17 @@ def list_pre_and_outs(logger, outputs, do_config, only_names, only_pre, only_gro logger.info('- '+str(c)) logger.info("") if outputs and not only_pre and not only_groups: - logger.info("Available outputs: 'comment/description' (name) [type]") + fmt = "name: comment/description [type]" if output_name_first else "'comment/description' (name) [type]" + logger.info("Available outputs: format is: `{}`".format(fmt)) for o in outputs: # Note: we can't do a `dry` config because some layer and field names can be validated only if we # load the schematic and the PCB. if do_config: config_output(o, dry=False) - logger.info('- '+str(o)) + if output_name_first: + logger.info('- {}: {} [{}]'.format(o.name, o.comment, o.type)) + else: + logger.info('- '+str(o)) logger.info("") if groups and not only_pre: logger.info("Available groups:") @@ -499,7 +504,8 @@ def main(): # Is just "list the available targets"? if args.list: - list_pre_and_outs(logger, outputs, args.config_outs, args.only_names, args.only_pre, args.only_groups) + list_pre_and_outs(logger, outputs, args.config_outs, args.only_names, args.only_pre, args.only_groups, + args.output_name_first) sys.exit(0) if args.list_variants: