From 46be478b1ddf91cd28b99e6afb65dafd65c94431 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 17 Dec 2024 13:55:45 -0800 Subject: [PATCH] docs(dev): improve help messages for component-info command --- dev/src/Command/ComponentInfoCommand.php | 25 +++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/dev/src/Command/ComponentInfoCommand.php b/dev/src/Command/ComponentInfoCommand.php index 989cf5c417a..0581d177f7e 100644 --- a/dev/src/Command/ComponentInfoCommand.php +++ b/dev/src/Command/ComponentInfoCommand.php @@ -79,20 +79,26 @@ protected function configure() ->addOption('component', 'c', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'get info for a single component', []) ->addOption('csv', '', InputOption::VALUE_OPTIONAL, 'export findings to csv.', false) ->addOption('fields', 'f', InputOption::VALUE_REQUIRED, sprintf( - "Comma-separated list of fields, \"all\" for all fields. The following fields are available: \n - %s\n" . - "NOTE: \"available_api_versions\", \"created_at\", and \"downloads\" are omited by default because they ". - "take a long time to load.\n", + 'Comma-separated list of fields. Prefix with "+" to add to default filters, or use "all" for all fields.' + . " The following fields are available: \n - %s\n" + . "\n EXAMPLE: --fields 'component_name,package_version,api_version'" + . "\n EXAMPLE: --fields '+migration_mode'" + . "\n EXAMPLE: --fields all" + . "\nNOTE: \"available_api_versions\", \"created_at\", and \"downloads\" are omited by default because they " + . "take a long time to load.", implode("\n - ", array_keys(self::$allFields)) )) ->addOption('filter', '', InputOption::VALUE_REQUIRED, - 'Comma-separated list of key-value filters. Supported operators are "=", "!=", "~=", and "!~=".' - . "\nExample: `--filter 'release_level=preview,migration_mode~=NEW_SURFACE_ONLY,migration_mode!~=MIGRATING'`'" + 'Comma-separated list of key-value filters.' + . "\nSupported operators are \"=\", \"!=\", \"~=\", and \"!~=\"." + . "\nEXAMPLE: --filter 'release_level=preview,migration_mode~=NEW_SURFACE_ONLY,migration_mode!~=MIGRATING'" ) ->addOption('sort', '', InputOption::VALUE_REQUIRED, 'field to sort by (with optional ASC/DESC suffix. e.g. "component_name DESC"' ) - ->addOption('token', 't', InputOption::VALUE_REQUIRED, 'Github token to use for authentication', '') - ->addOption('expanded', '', InputOption::VALUE_NONE, 'Break down each component by packages') + ->addOption('count', '', InputOption::VALUE_NONE, 'output number of components which match the provided filters') + ->addOption('expanded', '', InputOption::VALUE_NONE, 'Gives each component version its own row') + ->addOption('token', 't', InputOption::VALUE_REQUIRED, 'Github token to use for authentication. Used to prevent Github rate limiting.', '') ; } @@ -154,6 +160,11 @@ protected function execute(InputInterface $input, OutputInterface $output) } } + if ($input->getOption('count')) { + $output->writeln(count($rows)); + return 0; + } + // output the component data $headers = array_values(array_replace( $requestedFields,