@guanghechen/commander 4.7.4 → 4.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/browser.cjs +23 -11
- package/lib/cjs/node.cjs +23 -11
- package/lib/esm/browser.mjs +23 -11
- package/lib/esm/node.mjs +23 -11
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/lib/cjs/browser.cjs
CHANGED
|
@@ -715,8 +715,28 @@ class Command {
|
|
|
715
715
|
const desc = metadata.length > 0 ? `${arg.desc} ${metadata.join(' ')}` : arg.desc;
|
|
716
716
|
argumentsLines.push({ sig, desc });
|
|
717
717
|
}
|
|
718
|
+
const sortedOptions = [...allOptions].sort((a, b) => {
|
|
719
|
+
const optionRank = (option) => {
|
|
720
|
+
if (option.long === 'help') {
|
|
721
|
+
return 0;
|
|
722
|
+
}
|
|
723
|
+
if (option.long === 'version') {
|
|
724
|
+
return 1;
|
|
725
|
+
}
|
|
726
|
+
if (option.required === true) {
|
|
727
|
+
return 2;
|
|
728
|
+
}
|
|
729
|
+
return 3;
|
|
730
|
+
};
|
|
731
|
+
const rankA = optionRank(a);
|
|
732
|
+
const rankB = optionRank(b);
|
|
733
|
+
if (rankA !== rankB) {
|
|
734
|
+
return rankA - rankB;
|
|
735
|
+
}
|
|
736
|
+
return camelToKebabCase(a.long).localeCompare(camelToKebabCase(b.long));
|
|
737
|
+
});
|
|
718
738
|
const options = [];
|
|
719
|
-
for (const opt of
|
|
739
|
+
for (const opt of sortedOptions) {
|
|
720
740
|
const kebabLong = camelToKebabCase(opt.long);
|
|
721
741
|
let sig = opt.short ? `-${opt.short}, ` : ' ';
|
|
722
742
|
sig += `--${kebabLong}`;
|
|
@@ -734,21 +754,13 @@ class Command {
|
|
|
734
754
|
desc += ` [choices: ${opt.choices.map(choice => JSON.stringify(choice)).join(', ')}]`;
|
|
735
755
|
}
|
|
736
756
|
options.push({ sig, desc });
|
|
737
|
-
if (opt.type === 'boolean' &&
|
|
738
|
-
opt.args === 'none' &&
|
|
739
|
-
opt.long !== 'help' &&
|
|
740
|
-
opt.long !== 'version') {
|
|
741
|
-
options.push({
|
|
742
|
-
sig: ` --no-${kebabLong}`,
|
|
743
|
-
desc: `Negate --${kebabLong}`,
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
757
|
}
|
|
747
758
|
const commands = [];
|
|
748
759
|
if (this.#subcommandsList.length > 0) {
|
|
749
760
|
commands.push({ name: 'help', desc: 'Show help for a command' });
|
|
750
761
|
}
|
|
751
|
-
|
|
762
|
+
const sortedSubcommands = [...this.#subcommandsList].sort((a, b) => a.name.localeCompare(b.name));
|
|
763
|
+
for (const entry of sortedSubcommands) {
|
|
752
764
|
let name = entry.name;
|
|
753
765
|
if (entry.aliases.length > 0) {
|
|
754
766
|
name += `, ${entry.aliases.join(', ')}`;
|
package/lib/cjs/node.cjs
CHANGED
|
@@ -728,8 +728,28 @@ class Command {
|
|
|
728
728
|
const desc = metadata.length > 0 ? `${arg.desc} ${metadata.join(' ')}` : arg.desc;
|
|
729
729
|
argumentsLines.push({ sig, desc });
|
|
730
730
|
}
|
|
731
|
+
const sortedOptions = [...allOptions].sort((a, b) => {
|
|
732
|
+
const optionRank = (option) => {
|
|
733
|
+
if (option.long === 'help') {
|
|
734
|
+
return 0;
|
|
735
|
+
}
|
|
736
|
+
if (option.long === 'version') {
|
|
737
|
+
return 1;
|
|
738
|
+
}
|
|
739
|
+
if (option.required === true) {
|
|
740
|
+
return 2;
|
|
741
|
+
}
|
|
742
|
+
return 3;
|
|
743
|
+
};
|
|
744
|
+
const rankA = optionRank(a);
|
|
745
|
+
const rankB = optionRank(b);
|
|
746
|
+
if (rankA !== rankB) {
|
|
747
|
+
return rankA - rankB;
|
|
748
|
+
}
|
|
749
|
+
return camelToKebabCase$1(a.long).localeCompare(camelToKebabCase$1(b.long));
|
|
750
|
+
});
|
|
731
751
|
const options = [];
|
|
732
|
-
for (const opt of
|
|
752
|
+
for (const opt of sortedOptions) {
|
|
733
753
|
const kebabLong = camelToKebabCase$1(opt.long);
|
|
734
754
|
let sig = opt.short ? `-${opt.short}, ` : ' ';
|
|
735
755
|
sig += `--${kebabLong}`;
|
|
@@ -747,21 +767,13 @@ class Command {
|
|
|
747
767
|
desc += ` [choices: ${opt.choices.map(choice => JSON.stringify(choice)).join(', ')}]`;
|
|
748
768
|
}
|
|
749
769
|
options.push({ sig, desc });
|
|
750
|
-
if (opt.type === 'boolean' &&
|
|
751
|
-
opt.args === 'none' &&
|
|
752
|
-
opt.long !== 'help' &&
|
|
753
|
-
opt.long !== 'version') {
|
|
754
|
-
options.push({
|
|
755
|
-
sig: ` --no-${kebabLong}`,
|
|
756
|
-
desc: `Negate --${kebabLong}`,
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
770
|
}
|
|
760
771
|
const commands = [];
|
|
761
772
|
if (this.#subcommandsList.length > 0) {
|
|
762
773
|
commands.push({ name: 'help', desc: 'Show help for a command' });
|
|
763
774
|
}
|
|
764
|
-
|
|
775
|
+
const sortedSubcommands = [...this.#subcommandsList].sort((a, b) => a.name.localeCompare(b.name));
|
|
776
|
+
for (const entry of sortedSubcommands) {
|
|
765
777
|
let name = entry.name;
|
|
766
778
|
if (entry.aliases.length > 0) {
|
|
767
779
|
name += `, ${entry.aliases.join(', ')}`;
|
package/lib/esm/browser.mjs
CHANGED
|
@@ -713,8 +713,28 @@ class Command {
|
|
|
713
713
|
const desc = metadata.length > 0 ? `${arg.desc} ${metadata.join(' ')}` : arg.desc;
|
|
714
714
|
argumentsLines.push({ sig, desc });
|
|
715
715
|
}
|
|
716
|
+
const sortedOptions = [...allOptions].sort((a, b) => {
|
|
717
|
+
const optionRank = (option) => {
|
|
718
|
+
if (option.long === 'help') {
|
|
719
|
+
return 0;
|
|
720
|
+
}
|
|
721
|
+
if (option.long === 'version') {
|
|
722
|
+
return 1;
|
|
723
|
+
}
|
|
724
|
+
if (option.required === true) {
|
|
725
|
+
return 2;
|
|
726
|
+
}
|
|
727
|
+
return 3;
|
|
728
|
+
};
|
|
729
|
+
const rankA = optionRank(a);
|
|
730
|
+
const rankB = optionRank(b);
|
|
731
|
+
if (rankA !== rankB) {
|
|
732
|
+
return rankA - rankB;
|
|
733
|
+
}
|
|
734
|
+
return camelToKebabCase(a.long).localeCompare(camelToKebabCase(b.long));
|
|
735
|
+
});
|
|
716
736
|
const options = [];
|
|
717
|
-
for (const opt of
|
|
737
|
+
for (const opt of sortedOptions) {
|
|
718
738
|
const kebabLong = camelToKebabCase(opt.long);
|
|
719
739
|
let sig = opt.short ? `-${opt.short}, ` : ' ';
|
|
720
740
|
sig += `--${kebabLong}`;
|
|
@@ -732,21 +752,13 @@ class Command {
|
|
|
732
752
|
desc += ` [choices: ${opt.choices.map(choice => JSON.stringify(choice)).join(', ')}]`;
|
|
733
753
|
}
|
|
734
754
|
options.push({ sig, desc });
|
|
735
|
-
if (opt.type === 'boolean' &&
|
|
736
|
-
opt.args === 'none' &&
|
|
737
|
-
opt.long !== 'help' &&
|
|
738
|
-
opt.long !== 'version') {
|
|
739
|
-
options.push({
|
|
740
|
-
sig: ` --no-${kebabLong}`,
|
|
741
|
-
desc: `Negate --${kebabLong}`,
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
755
|
}
|
|
745
756
|
const commands = [];
|
|
746
757
|
if (this.#subcommandsList.length > 0) {
|
|
747
758
|
commands.push({ name: 'help', desc: 'Show help for a command' });
|
|
748
759
|
}
|
|
749
|
-
|
|
760
|
+
const sortedSubcommands = [...this.#subcommandsList].sort((a, b) => a.name.localeCompare(b.name));
|
|
761
|
+
for (const entry of sortedSubcommands) {
|
|
750
762
|
let name = entry.name;
|
|
751
763
|
if (entry.aliases.length > 0) {
|
|
752
764
|
name += `, ${entry.aliases.join(', ')}`;
|
package/lib/esm/node.mjs
CHANGED
|
@@ -726,8 +726,28 @@ class Command {
|
|
|
726
726
|
const desc = metadata.length > 0 ? `${arg.desc} ${metadata.join(' ')}` : arg.desc;
|
|
727
727
|
argumentsLines.push({ sig, desc });
|
|
728
728
|
}
|
|
729
|
+
const sortedOptions = [...allOptions].sort((a, b) => {
|
|
730
|
+
const optionRank = (option) => {
|
|
731
|
+
if (option.long === 'help') {
|
|
732
|
+
return 0;
|
|
733
|
+
}
|
|
734
|
+
if (option.long === 'version') {
|
|
735
|
+
return 1;
|
|
736
|
+
}
|
|
737
|
+
if (option.required === true) {
|
|
738
|
+
return 2;
|
|
739
|
+
}
|
|
740
|
+
return 3;
|
|
741
|
+
};
|
|
742
|
+
const rankA = optionRank(a);
|
|
743
|
+
const rankB = optionRank(b);
|
|
744
|
+
if (rankA !== rankB) {
|
|
745
|
+
return rankA - rankB;
|
|
746
|
+
}
|
|
747
|
+
return camelToKebabCase$1(a.long).localeCompare(camelToKebabCase$1(b.long));
|
|
748
|
+
});
|
|
729
749
|
const options = [];
|
|
730
|
-
for (const opt of
|
|
750
|
+
for (const opt of sortedOptions) {
|
|
731
751
|
const kebabLong = camelToKebabCase$1(opt.long);
|
|
732
752
|
let sig = opt.short ? `-${opt.short}, ` : ' ';
|
|
733
753
|
sig += `--${kebabLong}`;
|
|
@@ -745,21 +765,13 @@ class Command {
|
|
|
745
765
|
desc += ` [choices: ${opt.choices.map(choice => JSON.stringify(choice)).join(', ')}]`;
|
|
746
766
|
}
|
|
747
767
|
options.push({ sig, desc });
|
|
748
|
-
if (opt.type === 'boolean' &&
|
|
749
|
-
opt.args === 'none' &&
|
|
750
|
-
opt.long !== 'help' &&
|
|
751
|
-
opt.long !== 'version') {
|
|
752
|
-
options.push({
|
|
753
|
-
sig: ` --no-${kebabLong}`,
|
|
754
|
-
desc: `Negate --${kebabLong}`,
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
768
|
}
|
|
758
769
|
const commands = [];
|
|
759
770
|
if (this.#subcommandsList.length > 0) {
|
|
760
771
|
commands.push({ name: 'help', desc: 'Show help for a command' });
|
|
761
772
|
}
|
|
762
|
-
|
|
773
|
+
const sortedSubcommands = [...this.#subcommandsList].sort((a, b) => a.name.localeCompare(b.name));
|
|
774
|
+
for (const entry of sortedSubcommands) {
|
|
763
775
|
let name = entry.name;
|
|
764
776
|
if (entry.aliases.length > 0) {
|
|
765
777
|
name += `, ${entry.aliases.join(', ')}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/commander",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.5",
|
|
4
4
|
"description": "A minimal, type-safe command-line interface builder with fluent API",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guanghechen",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@guanghechen/
|
|
48
|
-
"@guanghechen/
|
|
47
|
+
"@guanghechen/env": "^2.0.2",
|
|
48
|
+
"@guanghechen/reporter": "^3.3.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "rollup -c ../../rollup.config.mjs",
|