Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(dev): improve help messages for component-info command #7946

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions dev/src/Command/ComponentInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.', '')
;
}

Expand Down Expand Up @@ -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,
Expand Down
Loading