breadc 0.8.3 → 0.8.4

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/dist/index.cjs CHANGED
@@ -547,7 +547,7 @@ function makeVersionCommand(name, config) {
547
547
  };
548
548
  return option;
549
549
  }
550
- function makeHelpCommand(name, config) {
550
+ function makeHelpCommand(name, config, allCommands) {
551
551
  function expandMessage(message) {
552
552
  const result = [];
553
553
  for (const row of message) {
@@ -586,6 +586,7 @@ function makeHelpCommand(name, config) {
586
586
  }
587
587
  return commands;
588
588
  }
589
+ const usage = allCommands.length === 0 ? `[OPTIONS]` : allCommands.length === 1 ? `[OPTIONS] ${allCommands[0].format}` : allCommands.some((c) => c._default) ? `[OPTIONS] [COMMAND]` : `[OPTIONS] <COMMAND>`;
589
590
  const command = {
590
591
  async callback(parsed) {
591
592
  const context = parsed.options.__context__;
@@ -599,6 +600,8 @@ function makeHelpCommand(name, config) {
599
600
  return void 0;
600
601
  }
601
602
  },
603
+ "",
604
+ `${color.bold(color.underline("Usage:"))} ${color.bold(name)} ${usage}`,
602
605
  () => {
603
606
  const cmds = expandCommands(cursor);
604
607
  if (cmds.length > 0) {
@@ -662,6 +665,7 @@ function makeHelpCommand(name, config) {
662
665
 
663
666
  function breadc(name, config = {}) {
664
667
  let defaultCommand = void 0;
668
+ const allCommands = [];
665
669
  const globalOptions = [];
666
670
  const container = makePluginContainer(config.plugins);
667
671
  const root = makeTreeNode({
@@ -671,7 +675,10 @@ function breadc(name, config = {}) {
671
675
  initContextOptions(defaultCommand._options, context);
672
676
  }
673
677
  initContextOptions(
674
- [makeHelpCommand(name, config), makeVersionCommand(name, config)],
678
+ [
679
+ makeHelpCommand(name, config, allCommands),
680
+ makeVersionCommand(name, config)
681
+ ],
675
682
  context
676
683
  );
677
684
  },
@@ -691,6 +698,7 @@ function breadc(name, config = {}) {
691
698
  if (command._default) {
692
699
  defaultCommand = command;
693
700
  }
701
+ allCommands.push(command);
694
702
  return command;
695
703
  },
696
704
  parse(args) {
package/dist/index.mjs CHANGED
@@ -543,7 +543,7 @@ function makeVersionCommand(name, config) {
543
543
  };
544
544
  return option;
545
545
  }
546
- function makeHelpCommand(name, config) {
546
+ function makeHelpCommand(name, config, allCommands) {
547
547
  function expandMessage(message) {
548
548
  const result = [];
549
549
  for (const row of message) {
@@ -582,6 +582,7 @@ function makeHelpCommand(name, config) {
582
582
  }
583
583
  return commands;
584
584
  }
585
+ const usage = allCommands.length === 0 ? `[OPTIONS]` : allCommands.length === 1 ? `[OPTIONS] ${allCommands[0].format}` : allCommands.some((c) => c._default) ? `[OPTIONS] [COMMAND]` : `[OPTIONS] <COMMAND>`;
585
586
  const command = {
586
587
  async callback(parsed) {
587
588
  const context = parsed.options.__context__;
@@ -595,6 +596,8 @@ function makeHelpCommand(name, config) {
595
596
  return void 0;
596
597
  }
597
598
  },
599
+ "",
600
+ `${bold(underline("Usage:"))} ${bold(name)} ${usage}`,
598
601
  () => {
599
602
  const cmds = expandCommands(cursor);
600
603
  if (cmds.length > 0) {
@@ -658,6 +661,7 @@ function makeHelpCommand(name, config) {
658
661
 
659
662
  function breadc(name, config = {}) {
660
663
  let defaultCommand = void 0;
664
+ const allCommands = [];
661
665
  const globalOptions = [];
662
666
  const container = makePluginContainer(config.plugins);
663
667
  const root = makeTreeNode({
@@ -667,7 +671,10 @@ function breadc(name, config = {}) {
667
671
  initContextOptions(defaultCommand._options, context);
668
672
  }
669
673
  initContextOptions(
670
- [makeHelpCommand(name, config), makeVersionCommand(name, config)],
674
+ [
675
+ makeHelpCommand(name, config, allCommands),
676
+ makeVersionCommand(name, config)
677
+ ],
671
678
  context
672
679
  );
673
680
  },
@@ -687,6 +694,7 @@ function breadc(name, config = {}) {
687
694
  if (command._default) {
688
695
  defaultCommand = command;
689
696
  }
697
+ allCommands.push(command);
690
698
  return command;
691
699
  },
692
700
  parse(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "breadc",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "Yet another Command Line Application Framework with fully strong TypeScript support",
5
5
  "keywords": [
6
6
  "breadc",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@breadc/color": "0.8.3"
37
+ "@breadc/color": "0.8.4"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^18.11.18",