Skip to content

Commit 84fd1f0

Browse files
authored
docs: help sort choices (#336)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 69f1cd1 commit 84fd1f0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ Arguments:
6767

6868
Options:
6969
--output-format=OUTPUT-FORMAT Which output format to use.
70-
{choices: "XML", "JSON"} [default: "XML"]
70+
{choices: "JSON", "XML"} [default: "XML"]
7171
--output-file=OUTPUT-FILE Path to the output file.
7272
Set to "-" to write to STDOUT [default: "-"]
7373
--omit=OMIT Omit dependency types.
7474
{choices: "dev", "plugin"} (multiple values allowed)
7575
--spec-version=SPEC-VERSION Which version of CycloneDX spec to use.
76-
{choices: "1.4", "1.3", "1.2", "1.1"} [default: "1.4"]
76+
{choices: "1.1", "1.2", "1.3", "1.4"} [default: "1.4"]
7777
--output-reproducible|--no-output-reproducible Whether to go the extra mile and make the output reproducible.
7878
This might result in loss of time- and random-based-values.
7979
--validate|--no-validate Validate the resulting output.

src/MakeBom/Options.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ class Options
102102
/**
103103
* @param scalar[] $values
104104
*/
105-
private static function formatChoice(array $values): string
105+
private static function formatChoice(array $values, int $sortFlag = \SORT_STRING): string
106106
{
107+
sort($values, $sortFlag);
108+
107109
return '{choices: "'.
108110
implode('", "', $values).
109111
'"}';
@@ -147,7 +149,7 @@ public function getDefinition(): InputDefinition
147149
null,
148150
InputOption::VALUE_REQUIRED,
149151
'Which version of CycloneDX spec to use.'.\PHP_EOL.
150-
self::formatChoice(array_keys(self::VALUE_SPEC_VERSION_MAP)),
152+
self::formatChoice(array_keys(self::VALUE_SPEC_VERSION_MAP), \SORT_NUMERIC),
151153
array_search($this->specVersion, self::VALUE_SPEC_VERSION_MAP, true),
152154
array_keys(self::VALUE_SPEC_VERSION_MAP)
153155
),

0 commit comments

Comments
 (0)