@flowscripter/dynamic-cli-framework 1.7.3 → 1.7.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.
Files changed (367) hide show
  1. package/cli-plugin.ts +1 -1
  2. package/dist/cli-plugin.d.ts +1 -1
  3. package/dist/cli-plugin.d.ts.map +1 -1
  4. package/dist/cli-plugin.js +25 -247
  5. package/dist/index.js +70 -105754
  6. package/dist/src/api/BaseCLIFeatureOptions.js +0 -0
  7. package/dist/src/api/CLI.js +0 -0
  8. package/dist/src/api/CLIConfig.js +0 -0
  9. package/dist/src/api/Context.js +0 -0
  10. package/dist/src/api/RunResult.js +73 -0
  11. package/dist/src/api/argument/Argument.js +0 -0
  12. package/dist/src/api/argument/ArgumentValueTypes.js +18 -0
  13. package/dist/src/api/argument/ComplexOption.js +1 -0
  14. package/dist/src/api/argument/GlobalCommandArgument.js +0 -0
  15. package/dist/src/api/argument/Option.js +0 -0
  16. package/dist/src/api/argument/Positional.js +0 -0
  17. package/dist/src/api/argument/SubCommandArgument.js +1 -0
  18. package/dist/src/api/command/Command.js +0 -0
  19. package/dist/src/api/command/GlobalCommand.js +0 -0
  20. package/dist/src/api/command/GlobalModifierCommand.js +0 -0
  21. package/dist/src/api/command/GroupCommand.js +0 -0
  22. package/dist/src/api/command/SubCommand.js +0 -0
  23. package/dist/src/api/command/UsageExample.js +0 -0
  24. package/dist/src/api/plugin/CLIPlugin.js +2 -0
  25. package/dist/src/api/plugin/CommandFactory.js +7 -0
  26. package/dist/src/api/plugin/ServiceProviderFactory.js +7 -0
  27. package/dist/src/api/plugin/createCLIPlugin.js +30 -0
  28. package/dist/src/api/service/ServiceProvider.js +0 -0
  29. package/dist/src/api/service/core/ArgumentPrompterService.js +1 -0
  30. package/dist/src/api/service/core/AsciiBannerGeneratorService.js +1 -0
  31. package/dist/src/api/service/core/CompletionService.js +8 -0
  32. package/dist/src/api/service/core/DataDumpGeneratorService.js +7 -0
  33. package/dist/src/api/service/core/ImagePrinterService.js +1 -0
  34. package/dist/src/api/service/core/KeyValueService.js +7 -0
  35. package/dist/src/api/service/core/PluginService.js +6 -0
  36. package/dist/src/api/service/core/PrettyPrinterService.js +1 -0
  37. package/dist/src/api/service/core/PrinterService.js +42 -0
  38. package/dist/src/api/service/core/PrompterService.js +10 -0
  39. package/dist/src/api/service/core/SecretService.js +0 -0
  40. package/dist/src/api/service/core/ShutdownService.js +1 -0
  41. package/dist/src/api/service/core/SyntaxHighlighterService.js +1 -0
  42. package/dist/src/api/service/core/Table.js +49 -0
  43. package/dist/src/api/service/core/TableGeneratorService.d.ts +1 -0
  44. package/dist/src/api/service/core/TableGeneratorService.d.ts.map +1 -1
  45. package/dist/src/api/service/core/TableGeneratorService.js +7 -0
  46. package/dist/src/api/service/core/TreePrinterService.js +1 -0
  47. package/dist/src/cli/BaseCLI.d.ts.map +1 -1
  48. package/dist/src/cli/BaseCLI.js +233 -0
  49. package/dist/src/cli/DefaultRuntimeCLI.js +20 -0
  50. package/dist/src/cli/DynamicPluginRuntimeCLI.js +50 -0
  51. package/dist/src/command/MultiCommandCliHelpCommand.js +238 -0
  52. package/dist/src/command/SingleCommandCliHelpCommand.js +104 -0
  53. package/dist/src/command/UsageCommand.js +16 -0
  54. package/dist/src/command/VersionCommand.js +13 -0
  55. package/dist/src/launcher.js +61 -0
  56. package/dist/src/runtime/DefaultContext.js +25 -0
  57. package/dist/src/runtime/argument/ArgumentTypeGuards.js +3 -0
  58. package/dist/src/runtime/command/CommandTypeGuards.js +12 -0
  59. package/dist/src/runtime/command/CommandValidator.js +371 -0
  60. package/dist/src/runtime/parser.js +105 -0
  61. package/dist/src/runtime/registry/CommandRegistry.js +0 -0
  62. package/dist/src/runtime/registry/DefaultCommandRegistry.js +190 -0
  63. package/dist/src/runtime/registry/DefaultServiceProviderRegistry.js +20 -0
  64. package/dist/src/runtime/registry/ServiceProviderRegistry.js +0 -0
  65. package/dist/src/runtime/runner.js +507 -0
  66. package/dist/src/runtime/scanner.js +244 -0
  67. package/dist/src/runtime/values/ValuePopulationResult.js +0 -0
  68. package/dist/src/runtime/values/argumentValueMerge.js +122 -0
  69. package/dist/src/runtime/values/argumentValueValidation.js +505 -0
  70. package/dist/src/runtime/values/globalCommandValuePopulation.js +67 -0
  71. package/dist/src/runtime/values/subCommandValuePopulation.js +549 -0
  72. package/dist/src/service/argumentPrompter/ArgumentPrompterServiceProvider.js +19 -0
  73. package/dist/src/service/argumentPrompter/DefaultArgumentPrompterService.js +197 -0
  74. package/dist/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.js +28 -0
  75. package/dist/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.js +233 -0
  76. package/dist/src/service/asciiBannerGenerator/standard.flf.json +3 -0
  77. package/dist/src/service/banner/BannerServiceProvider.js +60 -0
  78. package/dist/src/service/banner/command/NoBannerCommand.js +24 -0
  79. package/dist/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.js +51 -0
  80. package/dist/src/service/chiselAsciiBannerGenerator/chisel.flf.json +3 -0
  81. package/dist/src/service/completion/CompletionServiceProvider.d.ts +2 -1
  82. package/dist/src/service/completion/CompletionServiceProvider.d.ts.map +1 -1
  83. package/dist/src/service/completion/CompletionServiceProvider.js +160 -0
  84. package/dist/src/service/completion/DefaultCompletionService.js +279 -0
  85. package/dist/src/service/completion/command/CompletionCompleteSubCommand.d.ts +15 -0
  86. package/dist/src/service/completion/command/CompletionCompleteSubCommand.d.ts.map +1 -0
  87. package/dist/src/service/completion/command/CompletionCompleteSubCommand.js +37 -0
  88. package/dist/src/service/completion/command/CompletionGroupCommand.d.ts +14 -0
  89. package/dist/src/service/completion/command/CompletionGroupCommand.d.ts.map +1 -0
  90. package/dist/src/service/completion/command/CompletionGroupCommand.js +10 -0
  91. package/dist/src/service/completion/command/CompletionIntegrationSubCommand.d.ts +14 -0
  92. package/dist/src/service/completion/command/CompletionIntegrationSubCommand.d.ts.map +1 -0
  93. package/dist/src/service/completion/command/CompletionIntegrationSubCommand.js +67 -0
  94. package/dist/src/service/completion/shell/ShellHandler.js +0 -0
  95. package/dist/src/service/completion/shell/bash.js +39 -0
  96. package/dist/src/service/completion/shell/fish.js +35 -0
  97. package/dist/src/service/completion/shell/powershell.js +51 -0
  98. package/dist/src/service/completion/shell/zsh.js +42 -0
  99. package/dist/src/service/configuration/ConfigurationServiceProvider.js +482 -0
  100. package/dist/src/service/configuration/DefaultKeyValueService.js +80 -0
  101. package/dist/src/service/configuration/DefaultSecretService.js +60 -0
  102. package/dist/src/service/configuration/command/ConfigCommand.js +24 -0
  103. package/dist/src/service/configuration/command/DumpConfigCommand.js +18 -0
  104. package/dist/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.js +24 -0
  105. package/dist/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.js +59 -0
  106. package/dist/src/service/imagePrinter/DefaultImagePrinterService.js +10 -0
  107. package/dist/src/service/imagePrinter/ImagePrinterServiceProvider.js +20 -0
  108. package/dist/src/service/plugin/DefaultPluginService.js +21 -0
  109. package/dist/src/service/plugin/DefaultPluginServiceProvider.d.ts +1 -1
  110. package/dist/src/service/plugin/DefaultPluginServiceProvider.d.ts.map +1 -1
  111. package/dist/src/service/plugin/DefaultPluginServiceProvider.js +21 -0
  112. package/dist/src/service/plugin/command/PluginAddSubCommand.d.ts +17 -0
  113. package/dist/src/service/plugin/command/PluginAddSubCommand.d.ts.map +1 -0
  114. package/dist/src/service/plugin/command/PluginAddSubCommand.js +49 -0
  115. package/dist/src/service/plugin/command/PluginGroupCommand.d.ts +12 -0
  116. package/dist/src/service/plugin/command/PluginGroupCommand.d.ts.map +1 -0
  117. package/dist/src/service/plugin/command/PluginGroupCommand.js +21 -0
  118. package/dist/src/service/plugin/command/PluginListSubCommand.d.ts +12 -0
  119. package/dist/src/service/plugin/command/PluginListSubCommand.d.ts.map +1 -0
  120. package/dist/src/service/plugin/command/PluginListSubCommand.js +25 -0
  121. package/dist/src/service/plugin/command/PluginRemoveSubCommand.d.ts +17 -0
  122. package/dist/src/service/plugin/command/PluginRemoveSubCommand.d.ts.map +1 -0
  123. package/dist/src/service/plugin/command/PluginRemoveSubCommand.js +24 -0
  124. package/dist/src/service/plugin/command/PluginSearchSubCommand.d.ts +18 -0
  125. package/dist/src/service/plugin/command/PluginSearchSubCommand.d.ts.map +1 -0
  126. package/dist/src/service/plugin/command/PluginSearchSubCommand.js +34 -0
  127. package/dist/src/service/plugin/command/PluginUpgradeSubCommand.d.ts +12 -0
  128. package/dist/src/service/plugin/command/PluginUpgradeSubCommand.d.ts.map +1 -0
  129. package/dist/src/service/plugin/command/PluginUpgradeSubCommand.js +25 -0
  130. package/dist/src/service/plugin/command/getPluginId.d.ts +3 -0
  131. package/dist/src/service/plugin/command/getPluginId.d.ts.map +1 -0
  132. package/dist/src/service/plugin/command/getPluginId.js +3 -0
  133. package/dist/src/service/prettyPrinter/DefaultPrettyPrinterService.js +45 -0
  134. package/dist/src/service/prettyPrinter/PrettyPrinterServiceProvider.js +28 -0
  135. package/dist/src/service/printer/DefaultPrinterService.js +250 -0
  136. package/dist/src/service/printer/PrinterServiceProvider.js +43 -0
  137. package/dist/src/service/printer/command/DarkModeCommand.js +24 -0
  138. package/dist/src/service/printer/command/LogLevelCommand.js +41 -0
  139. package/dist/src/service/printer/command/NoColorCommand.js +24 -0
  140. package/dist/src/service/printer/command/NoHyperlinksCommand.js +21 -0
  141. package/dist/src/service/printer/terminal/Color.js +15 -0
  142. package/dist/src/service/printer/terminal/Progress.js +271 -0
  143. package/dist/src/service/printer/terminal/Spinner.js +83 -0
  144. package/dist/src/service/printer/terminal/Theme.js +26 -0
  145. package/dist/src/service/prompter/DefaultPrompterService.js +52 -0
  146. package/dist/src/service/prompter/PrompterServiceProvider.js +20 -0
  147. package/dist/src/service/prompter/command/NoPromptCommand.js +21 -0
  148. package/dist/src/service/prompter/prompt/PromptContext.js +22 -0
  149. package/dist/src/service/prompter/prompt/promptAcknowledge.js +19 -0
  150. package/dist/src/service/prompter/prompt/promptMultiSelect.js +74 -0
  151. package/dist/src/service/prompter/prompt/promptOpenUrl.js +70 -0
  152. package/dist/src/service/prompter/prompt/promptSingleSelect.js +73 -0
  153. package/dist/src/service/prompter/prompt/promptText.js +75 -0
  154. package/dist/src/service/prompter/prompt/promptToggle.js +21 -0
  155. package/dist/src/service/shutdown/DefaultShutdownService.js +16 -0
  156. package/dist/src/service/shutdown/ShutdownServiceProvider.js +60 -0
  157. package/dist/src/service/shutdown/ShutdownState.js +5 -0
  158. package/dist/src/service/syntaxHighlighter/DefaultSyntaxHighlighterService.js +54 -0
  159. package/dist/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.js +32 -0
  160. package/dist/src/service/tableGenerator/DefaultTableGeneratorService.d.ts +3 -1
  161. package/dist/src/service/tableGenerator/DefaultTableGeneratorService.d.ts.map +1 -1
  162. package/dist/src/service/tableGenerator/DefaultTableGeneratorService.js +344 -0
  163. package/dist/src/service/tableGenerator/TableGeneratorServiceProvider.js +26 -0
  164. package/dist/src/service/treePrinter/DefaultTreePrinterService.js +35 -0
  165. package/dist/src/service/treePrinter/TreePrinterServiceProvider.js +24 -0
  166. package/dist/src/terminal/Ansi.js +23 -0
  167. package/dist/src/terminal/ImageRenderer.js +164 -0
  168. package/dist/src/terminal/KeyReader.js +13 -0
  169. package/dist/src/terminal/PngDecoder.js +115 -0
  170. package/dist/src/terminal/Styler.js +0 -0
  171. package/dist/src/terminal/Terminal.js +0 -0
  172. package/dist/src/terminal/TtyKeyReader.js +87 -0
  173. package/dist/src/terminal/TtyStyler.js +55 -0
  174. package/dist/src/terminal/TtyTerminal.js +52 -0
  175. package/dist/src/terminal/supportsHyperlinks.js +95 -0
  176. package/dist/src/util/configHelper.js +61 -0
  177. package/dist/src/util/envVarHelper.js +216 -0
  178. package/dist/src/util/helpHelper.d.ts.map +1 -1
  179. package/dist/src/util/helpHelper.js +497 -0
  180. package/dist/src/util/logger.js +81 -0
  181. package/dist/src/util/runnerHelper.js +80 -0
  182. package/package.json +2 -2
  183. package/src/api/service/core/TableGeneratorService.ts +1 -0
  184. package/src/cli/BaseCLI.ts +4 -18
  185. package/src/service/completion/CompletionServiceProvider.ts +16 -2
  186. package/src/service/completion/command/CompletionCompleteSubCommand.ts +59 -0
  187. package/src/service/completion/command/CompletionGroupCommand.ts +21 -0
  188. package/src/{command/CompletionCommand.ts → service/completion/command/CompletionIntegrationSubCommand.ts} +12 -73
  189. package/src/service/completion/shell/bash.ts +1 -1
  190. package/src/service/completion/shell/fish.ts +1 -1
  191. package/src/service/completion/shell/powershell.ts +1 -1
  192. package/src/service/completion/shell/zsh.ts +1 -1
  193. package/src/service/plugin/DefaultPluginServiceProvider.ts +2 -2
  194. package/src/service/plugin/command/PluginAddSubCommand.ts +64 -0
  195. package/src/service/plugin/command/PluginGroupCommand.ts +27 -0
  196. package/src/service/plugin/command/PluginListSubCommand.ts +33 -0
  197. package/src/service/plugin/command/PluginRemoveSubCommand.ts +32 -0
  198. package/src/service/plugin/command/PluginSearchSubCommand.ts +42 -0
  199. package/src/service/plugin/command/PluginUpgradeSubCommand.ts +36 -0
  200. package/src/service/plugin/command/getPluginId.ts +5 -0
  201. package/src/service/tableGenerator/DefaultTableGeneratorService.ts +6 -1
  202. package/src/util/helpHelper.ts +1 -2
  203. package/dist/src/command/CompletionCommand.d.ts +0 -32
  204. package/dist/src/command/CompletionCommand.d.ts.map +0 -1
  205. package/dist/src/command/PluginCommand.d.ts +0 -67
  206. package/dist/src/command/PluginCommand.d.ts.map +0 -1
  207. package/dist/tests/cli/BaseCLI.test.d.ts +0 -2
  208. package/dist/tests/cli/BaseCLI.test.d.ts.map +0 -1
  209. package/dist/tests/cli/DynamicPluginRuntimeCLI.test.d.ts +0 -2
  210. package/dist/tests/cli/DynamicPluginRuntimeCLI.test.d.ts.map +0 -1
  211. package/dist/tests/command/CompletionCommand.test.d.ts +0 -2
  212. package/dist/tests/command/CompletionCommand.test.d.ts.map +0 -1
  213. package/dist/tests/command/MultiCommandCliHelpCommand.test.d.ts +0 -2
  214. package/dist/tests/command/MultiCommandCliHelpCommand.test.d.ts.map +0 -1
  215. package/dist/tests/command/PluginCommand.test.d.ts +0 -2
  216. package/dist/tests/command/PluginCommand.test.d.ts.map +0 -1
  217. package/dist/tests/command/SingleCommandCliHelpCommand.test.d.ts +0 -2
  218. package/dist/tests/command/SingleCommandCliHelpCommand.test.d.ts.map +0 -1
  219. package/dist/tests/command/UsageCommand.test.d.ts +0 -2
  220. package/dist/tests/command/UsageCommand.test.d.ts.map +0 -1
  221. package/dist/tests/command/VersionCommand.test.d.ts +0 -2
  222. package/dist/tests/command/VersionCommand.test.d.ts.map +0 -1
  223. package/dist/tests/fixtures/CLIConfig.d.ts +0 -3
  224. package/dist/tests/fixtures/CLIConfig.d.ts.map +0 -1
  225. package/dist/tests/fixtures/Command.d.ts +0 -20
  226. package/dist/tests/fixtures/Command.d.ts.map +0 -1
  227. package/dist/tests/fixtures/CommandRegistry.d.ts +0 -4
  228. package/dist/tests/fixtures/CommandRegistry.d.ts.map +0 -1
  229. package/dist/tests/fixtures/ConfigurationServiceProvider.d.ts +0 -10
  230. package/dist/tests/fixtures/ConfigurationServiceProvider.d.ts.map +0 -1
  231. package/dist/tests/fixtures/Context.d.ts +0 -4
  232. package/dist/tests/fixtures/Context.d.ts.map +0 -1
  233. package/dist/tests/fixtures/ServiceProviderRegistry.d.ts +0 -4
  234. package/dist/tests/fixtures/ServiceProviderRegistry.d.ts.map +0 -1
  235. package/dist/tests/fixtures/StreamString.d.ts +0 -10
  236. package/dist/tests/fixtures/StreamString.d.ts.map +0 -1
  237. package/dist/tests/fixtures/prettierPluginFoo.d.ts +0 -4
  238. package/dist/tests/fixtures/prettierPluginFoo.d.ts.map +0 -1
  239. package/dist/tests/fixtures/util.d.ts +0 -8
  240. package/dist/tests/fixtures/util.d.ts.map +0 -1
  241. package/dist/tests/runtime/DefaultContext.test.d.ts +0 -2
  242. package/dist/tests/runtime/DefaultContext.test.d.ts.map +0 -1
  243. package/dist/tests/runtime/argument/ArgumentTypeGuards.test.d.ts +0 -2
  244. package/dist/tests/runtime/argument/ArgumentTypeGuards.test.d.ts.map +0 -1
  245. package/dist/tests/runtime/command/CommandTypeGuards.test.d.ts +0 -2
  246. package/dist/tests/runtime/command/CommandTypeGuards.test.d.ts.map +0 -1
  247. package/dist/tests/runtime/command/CommandValidator.test.d.ts +0 -2
  248. package/dist/tests/runtime/command/CommandValidator.test.d.ts.map +0 -1
  249. package/dist/tests/runtime/parser.test.d.ts +0 -2
  250. package/dist/tests/runtime/parser.test.d.ts.map +0 -1
  251. package/dist/tests/runtime/registry/DefaultCommandRegistry.test.d.ts +0 -2
  252. package/dist/tests/runtime/registry/DefaultCommandRegistry.test.d.ts.map +0 -1
  253. package/dist/tests/runtime/registry/DefaultServiceProviderRegistry.test.d.ts +0 -2
  254. package/dist/tests/runtime/registry/DefaultServiceProviderRegistry.test.d.ts.map +0 -1
  255. package/dist/tests/runtime/runner.test.d.ts +0 -2
  256. package/dist/tests/runtime/runner.test.d.ts.map +0 -1
  257. package/dist/tests/runtime/scanner.test.d.ts +0 -2
  258. package/dist/tests/runtime/scanner.test.d.ts.map +0 -1
  259. package/dist/tests/runtime/values/argumentValueMerge.test.d.ts +0 -2
  260. package/dist/tests/runtime/values/argumentValueMerge.test.d.ts.map +0 -1
  261. package/dist/tests/runtime/values/argumentValueValidation.test.d.ts +0 -2
  262. package/dist/tests/runtime/values/argumentValueValidation.test.d.ts.map +0 -1
  263. package/dist/tests/runtime/values/globalCommandValuePopulation.test.d.ts +0 -2
  264. package/dist/tests/runtime/values/globalCommandValuePopulation.test.d.ts.map +0 -1
  265. package/dist/tests/runtime/values/subCommandValuePopulation.test.d.ts +0 -2
  266. package/dist/tests/runtime/values/subCommandValuePopulation.test.d.ts.map +0 -1
  267. package/dist/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.d.ts +0 -2
  268. package/dist/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.d.ts.map +0 -1
  269. package/dist/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.d.ts +0 -2
  270. package/dist/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.d.ts.map +0 -1
  271. package/dist/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.d.ts +0 -2
  272. package/dist/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.d.ts.map +0 -1
  273. package/dist/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.d.ts +0 -2
  274. package/dist/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.d.ts.map +0 -1
  275. package/dist/tests/service/banner/BannerServiceProvider.test.d.ts +0 -2
  276. package/dist/tests/service/banner/BannerServiceProvider.test.d.ts.map +0 -1
  277. package/dist/tests/service/banner/command/NoBannerCommand.test.d.ts +0 -2
  278. package/dist/tests/service/banner/command/NoBannerCommand.test.d.ts.map +0 -1
  279. package/dist/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.d.ts +0 -2
  280. package/dist/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.d.ts.map +0 -1
  281. package/dist/tests/service/completion/CompletionServiceProvider.test.d.ts +0 -2
  282. package/dist/tests/service/completion/CompletionServiceProvider.test.d.ts.map +0 -1
  283. package/dist/tests/service/completion/DefaultCompletionService.test.d.ts +0 -2
  284. package/dist/tests/service/completion/DefaultCompletionService.test.d.ts.map +0 -1
  285. package/dist/tests/service/completion/shell/bash.test.d.ts +0 -2
  286. package/dist/tests/service/completion/shell/bash.test.d.ts.map +0 -1
  287. package/dist/tests/service/completion/shell/fish.test.d.ts +0 -2
  288. package/dist/tests/service/completion/shell/fish.test.d.ts.map +0 -1
  289. package/dist/tests/service/completion/shell/powershell.test.d.ts +0 -2
  290. package/dist/tests/service/completion/shell/powershell.test.d.ts.map +0 -1
  291. package/dist/tests/service/completion/shell/zsh.test.d.ts +0 -2
  292. package/dist/tests/service/completion/shell/zsh.test.d.ts.map +0 -1
  293. package/dist/tests/service/configuration/ConfigurationServiceProvider.test.d.ts +0 -2
  294. package/dist/tests/service/configuration/ConfigurationServiceProvider.test.d.ts.map +0 -1
  295. package/dist/tests/service/configuration/DefaultKeyValueService.test.d.ts +0 -2
  296. package/dist/tests/service/configuration/DefaultKeyValueService.test.d.ts.map +0 -1
  297. package/dist/tests/service/configuration/DefaultSecretService.test.d.ts +0 -2
  298. package/dist/tests/service/configuration/DefaultSecretService.test.d.ts.map +0 -1
  299. package/dist/tests/service/configuration/command/ConfigCommand.test.d.ts +0 -2
  300. package/dist/tests/service/configuration/command/ConfigCommand.test.d.ts.map +0 -1
  301. package/dist/tests/service/configuration/command/DumpConfigCommand.test.d.ts +0 -2
  302. package/dist/tests/service/configuration/command/DumpConfigCommand.test.d.ts.map +0 -1
  303. package/dist/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.d.ts +0 -2
  304. package/dist/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.d.ts.map +0 -1
  305. package/dist/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.d.ts +0 -2
  306. package/dist/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.d.ts.map +0 -1
  307. package/dist/tests/service/imagePrinter/DefaultImagePrinterService.test.d.ts +0 -2
  308. package/dist/tests/service/imagePrinter/DefaultImagePrinterService.test.d.ts.map +0 -1
  309. package/dist/tests/service/imagePrinter/ImagePrinterServiceProvider.test.d.ts +0 -2
  310. package/dist/tests/service/imagePrinter/ImagePrinterServiceProvider.test.d.ts.map +0 -1
  311. package/dist/tests/service/plugin/DefaultPluginServiceProvider.test.d.ts +0 -2
  312. package/dist/tests/service/plugin/DefaultPluginServiceProvider.test.d.ts.map +0 -1
  313. package/dist/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.d.ts +0 -2
  314. package/dist/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.d.ts.map +0 -1
  315. package/dist/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.d.ts +0 -2
  316. package/dist/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.d.ts.map +0 -1
  317. package/dist/tests/service/printer/DefaultPrinterService.test.d.ts +0 -2
  318. package/dist/tests/service/printer/DefaultPrinterService.test.d.ts.map +0 -1
  319. package/dist/tests/service/printer/PrinterServiceProvider.test.d.ts +0 -2
  320. package/dist/tests/service/printer/PrinterServiceProvider.test.d.ts.map +0 -1
  321. package/dist/tests/service/printer/command/DarkModeCommand.test.d.ts +0 -2
  322. package/dist/tests/service/printer/command/DarkModeCommand.test.d.ts.map +0 -1
  323. package/dist/tests/service/printer/command/LogLevelCommand.test.d.ts +0 -2
  324. package/dist/tests/service/printer/command/LogLevelCommand.test.d.ts.map +0 -1
  325. package/dist/tests/service/printer/command/NoColorCommand.test.d.ts +0 -2
  326. package/dist/tests/service/printer/command/NoColorCommand.test.d.ts.map +0 -1
  327. package/dist/tests/service/printer/command/NoHyperlinksCommand.test.d.ts +0 -2
  328. package/dist/tests/service/printer/command/NoHyperlinksCommand.test.d.ts.map +0 -1
  329. package/dist/tests/service/printer/terminal/Progress.test.d.ts +0 -2
  330. package/dist/tests/service/printer/terminal/Progress.test.d.ts.map +0 -1
  331. package/dist/tests/service/printer/terminal/Spinner.test.d.ts +0 -2
  332. package/dist/tests/service/printer/terminal/Spinner.test.d.ts.map +0 -1
  333. package/dist/tests/service/prompter/DefaultPrompterService.test.d.ts +0 -2
  334. package/dist/tests/service/prompter/DefaultPrompterService.test.d.ts.map +0 -1
  335. package/dist/tests/service/prompter/PrompterServiceProvider.test.d.ts +0 -2
  336. package/dist/tests/service/prompter/PrompterServiceProvider.test.d.ts.map +0 -1
  337. package/dist/tests/service/prompter/command/NoPromptCommand.test.d.ts +0 -2
  338. package/dist/tests/service/prompter/command/NoPromptCommand.test.d.ts.map +0 -1
  339. package/dist/tests/service/prompter/prompt/PromptContext.test.d.ts +0 -2
  340. package/dist/tests/service/prompter/prompt/PromptContext.test.d.ts.map +0 -1
  341. package/dist/tests/service/shutdown/ShutdownServiceProvider.test.d.ts +0 -2
  342. package/dist/tests/service/shutdown/ShutdownServiceProvider.test.d.ts.map +0 -1
  343. package/dist/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.d.ts +0 -2
  344. package/dist/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.d.ts.map +0 -1
  345. package/dist/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.d.ts +0 -2
  346. package/dist/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.d.ts.map +0 -1
  347. package/dist/tests/service/tableGenerator/DefaultTableGeneratorService.test.d.ts +0 -2
  348. package/dist/tests/service/tableGenerator/DefaultTableGeneratorService.test.d.ts.map +0 -1
  349. package/dist/tests/service/tableGenerator/TableGeneratorServiceProvider.test.d.ts +0 -2
  350. package/dist/tests/service/tableGenerator/TableGeneratorServiceProvider.test.d.ts.map +0 -1
  351. package/dist/tests/service/treePrinter/DefaultTreePrinterService.test.d.ts +0 -2
  352. package/dist/tests/service/treePrinter/DefaultTreePrinterService.test.d.ts.map +0 -1
  353. package/dist/tests/service/treePrinter/TreePrinterServiceProvider.test.d.ts +0 -2
  354. package/dist/tests/service/treePrinter/TreePrinterServiceProvider.test.d.ts.map +0 -1
  355. package/dist/tests/terminal/ImageRenderer.test.d.ts +0 -2
  356. package/dist/tests/terminal/ImageRenderer.test.d.ts.map +0 -1
  357. package/dist/tests/terminal/PngDecoder.test.d.ts +0 -2
  358. package/dist/tests/terminal/PngDecoder.test.d.ts.map +0 -1
  359. package/dist/tests/terminal/supportsHyperlinks.test.d.ts +0 -2
  360. package/dist/tests/terminal/supportsHyperlinks.test.d.ts.map +0 -1
  361. package/dist/tests/util/configHelper.test.d.ts +0 -2
  362. package/dist/tests/util/configHelper.test.d.ts.map +0 -1
  363. package/dist/tests/util/envVarHelper.test.d.ts +0 -2
  364. package/dist/tests/util/envVarHelper.test.d.ts.map +0 -1
  365. package/dist/tests/util/logger.test.d.ts +0 -2
  366. package/dist/tests/util/logger.test.d.ts.map +0 -1
  367. package/src/command/PluginCommand.ts +0 -197
@@ -0,0 +1,20 @@
1
+ import process from "node:process";
2
+ import BaseCLI from "./BaseCLI.js";
3
+ import { Writable } from "node:stream";
4
+ import TtyTerminal from "../terminal/TtyTerminal.js";
5
+ import TtyKeyReader from "../terminal/TtyKeyReader.js";
6
+ import TtyStyler from "../terminal/TtyStyler.js";
7
+ import supportsColor from "supports-color";
8
+ import supportsHyperlinks from "../terminal/supportsHyperlinks.js";
9
+ /**
10
+ * Default Bun implementation of a {@link CLI} using `process.stdout`, `process.stderr` and `process.argv`.
11
+ */
12
+ export default class DefaultRuntimeCLI extends BaseCLI {
13
+ constructor(cliConfig, options) {
14
+ super(cliConfig, Writable.toWeb(process.stdout), Writable.toWeb(process.stderr), supportsColor.stdout !== false, supportsColor.stderr !== false, new TtyTerminal(process.stdout), new TtyTerminal(process.stderr), new TtyStyler(supportsColor.stderr === false ? 1 : supportsColor.stderr.level, supportsHyperlinks(process.stderr)), new TtyKeyReader(process.stdin), { promptingEnabled: process.stdin.isTTY === true, ...options });
15
+ }
16
+ async run() {
17
+ const runResult = await super.run(process.argv.slice(2));
18
+ process.exit(runResult.runState);
19
+ }
20
+ }
@@ -0,0 +1,50 @@
1
+ import { RunState } from "../api/RunResult.js";
2
+ import DefaultRuntimeCLI from "./DefaultRuntimeCLI.js";
3
+ import DefaultPluginServiceProvider from "../service/plugin/DefaultPluginServiceProvider.js";
4
+ import { DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT } from "../api/plugin/CommandFactory.js";
5
+ import { DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT } from "../api/plugin/ServiceProviderFactory.js";
6
+ import process from "node:process";
7
+ /**
8
+ * Extension of {@link DefaultRuntimeCLI} that discovers and loads installed plugins before running.
9
+ *
10
+ * On each invocation of {@link run}, all locally installed plugins are discovered via the
11
+ * {@link MarketplacePluginManager}. Commands provided by {@link CommandFactory} extensions and
12
+ * service providers provided by {@link ServiceProviderFactory} extensions are registered before
13
+ * the runner starts, so they participate in the full initialization lifecycle.
14
+ */
15
+ export default class DynamicPluginRuntimeCLI extends DefaultRuntimeCLI {
16
+ #pluginManager;
17
+ constructor(cliConfig, pluginManager, options) {
18
+ super(cliConfig, options);
19
+ this.#pluginManager = pluginManager;
20
+ this.addServiceProvider(new DefaultPluginServiceProvider(pluginManager));
21
+ }
22
+ async run() {
23
+ try {
24
+ await this.loadPlugins();
25
+ }
26
+ catch (err) {
27
+ console.error(err);
28
+ process.exit(RunState.RUNTIME_ERROR);
29
+ }
30
+ return super.run();
31
+ }
32
+ async loadPlugins() {
33
+ await this.#pluginManager.registerExtensions(DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT);
34
+ await this.#pluginManager.registerExtensions(DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT);
35
+ const commandFactoryExtensions = await this.#pluginManager.getRegisteredExtensions(DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT);
36
+ for (const ext of commandFactoryExtensions) {
37
+ const factory = (await this.#pluginManager.instantiate(ext.extensionHandle));
38
+ for (const command of factory.getCommands()) {
39
+ this.addCommand(command);
40
+ }
41
+ }
42
+ const spFactoryExtensions = await this.#pluginManager.getRegisteredExtensions(DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT);
43
+ for (const ext of spFactoryExtensions) {
44
+ const factory = (await this.#pluginManager.instantiate(ext.extensionHandle));
45
+ for (const sp of factory.getServiceProviders()) {
46
+ this.addServiceProvider(sp);
47
+ }
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,238 @@
1
+ import { ArgumentValueTypeName, } from "../api/argument/ArgumentValueTypes.js";
2
+ import { findPossibleCommandNames, getCommandArgsHelpSections, getCommandExamplesHelpSections, getGlobalArgumentHelpEntry, getMultiCommandAppSyntax, getSubCommandArgumentsSyntax, printHelpSections, } from "../util/helpHelper.js";
3
+ import { Icon, PRINTER_SERVICE_ID } from "../api/service/core/PrinterService.js";
4
+ import { TABLE_GENERATOR_SERVICE_ID } from "../api/service/core/TableGeneratorService.js";
5
+ /**
6
+ * Provides common implementation for both {@link MultiCommandCliHelpGlobalCommand} and {@link MultiCommandCliHelpSubCommand}.
7
+ */
8
+ class MultiCommandCliAbstractHelpCommand {
9
+ name = "help";
10
+ description = "Display application help";
11
+ #includeEnvVars;
12
+ #commandRegistry;
13
+ constructor(includeEnvVars, commandRegistry) {
14
+ this.#includeEnvVars = includeEnvVars;
15
+ this.#commandRegistry = commandRegistry;
16
+ }
17
+ #getGlobalCommandsHelpSection(context, title, globalCommands) {
18
+ const globalCommandsSection = {
19
+ title,
20
+ helpEntries: [],
21
+ };
22
+ globalCommands.forEach((globalCommand) => {
23
+ const { syntax, description } = getGlobalArgumentHelpEntry(context.cliConfig, this.#includeEnvVars, globalCommand);
24
+ globalCommandsSection.helpEntries.push({
25
+ syntax: `--${globalCommand.name} ${syntax}`,
26
+ description,
27
+ });
28
+ if (globalCommand.shortAlias !== undefined) {
29
+ globalCommandsSection.helpEntries.push({
30
+ syntax: `-${globalCommand.shortAlias} ${syntax}`,
31
+ description,
32
+ });
33
+ }
34
+ });
35
+ globalCommandsSection.helpEntries.sort((a, b) => a.syntax.localeCompare(b.syntax));
36
+ return globalCommandsSection;
37
+ }
38
+ #getGenericHelpSections(context, globalModifierCommands, globalCommands, groupCommands, subCommands) {
39
+ const globalPrefix = groupCommands.length > 0 || subCommands.length > 0 ? "Global " : "";
40
+ const helpSections = [];
41
+ if (globalModifierCommands.length > 0) {
42
+ helpSections.push(this.#getGlobalCommandsHelpSection(context, `${globalPrefix}Options`, globalModifierCommands));
43
+ }
44
+ if (globalCommands.length > 0) {
45
+ helpSections.push(this.#getGlobalCommandsHelpSection(context, `${globalPrefix}Commands`, globalCommands));
46
+ }
47
+ groupCommands.forEach((groupCommand) => {
48
+ const visibleMemberSubCommands = groupCommand.memberSubCommands.filter((memberCommand) => !memberCommand.disableGenericHelpDisplay);
49
+ if (visibleMemberSubCommands.length === 0)
50
+ return;
51
+ const topicSection = {
52
+ title: `${groupCommand.name.charAt(0).toUpperCase() + groupCommand.name.slice(1)} Commands`,
53
+ helpEntries: [],
54
+ };
55
+ visibleMemberSubCommands.forEach((memberCommand) => {
56
+ topicSection.helpEntries.push({
57
+ syntax: `${groupCommand.name}:${memberCommand.name}`,
58
+ description: memberCommand.description,
59
+ });
60
+ });
61
+ topicSection.helpEntries.sort((a, b) => a.syntax.localeCompare(b.syntax));
62
+ helpSections.push(topicSection);
63
+ });
64
+ if (subCommands.length > 0) {
65
+ const subCommandsByTopic = new Map();
66
+ const otherSubCommands = [];
67
+ subCommands.forEach((subCommand) => {
68
+ if (subCommand.helpTopic === undefined) {
69
+ otherSubCommands.push(subCommand);
70
+ }
71
+ else {
72
+ const commands = subCommandsByTopic.get(subCommand.helpTopic) || [];
73
+ commands.push(subCommand);
74
+ subCommandsByTopic.set(subCommand.helpTopic, commands);
75
+ }
76
+ });
77
+ for (const key of subCommandsByTopic.keys()) {
78
+ const topicCommands = subCommandsByTopic.get(key);
79
+ if (topicCommands !== undefined) {
80
+ const topicSection = {
81
+ title: `${key.charAt(0).toUpperCase() + key.slice(1)} Commands`,
82
+ helpEntries: [],
83
+ };
84
+ topicCommands.sort((a, b) => a.name.localeCompare(b.name));
85
+ topicCommands.forEach((subCommand) => {
86
+ topicSection.helpEntries.push({
87
+ syntax: subCommand.name,
88
+ description: subCommand.description,
89
+ });
90
+ });
91
+ helpSections.push(topicSection);
92
+ }
93
+ }
94
+ if (otherSubCommands.length > 0) {
95
+ const topicSection = {
96
+ title: subCommandsByTopic.size > 0 || groupCommands.length > 0
97
+ ? "Other Commands"
98
+ : "Sub-Commands",
99
+ helpEntries: [],
100
+ };
101
+ otherSubCommands.sort((a, b) => a.name.localeCompare(b.name));
102
+ otherSubCommands.forEach((subCommand) => {
103
+ topicSection.helpEntries.push({
104
+ syntax: subCommand.name,
105
+ description: subCommand.description,
106
+ });
107
+ });
108
+ helpSections.push(topicSection);
109
+ }
110
+ }
111
+ return helpSections;
112
+ }
113
+ async printGenericHelp(context) {
114
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID);
115
+ const tableGeneratorService = context.getServiceById(TABLE_GENERATOR_SERVICE_ID);
116
+ const globalModifierCommands = this.#commandRegistry
117
+ .getGlobalModifierCommands()
118
+ .filter((command) => !command.disableGenericHelpDisplay);
119
+ const globalCommands = this.#commandRegistry
120
+ .getGlobalCommands()
121
+ .filter((command) => !command.disableGenericHelpDisplay);
122
+ const groupCommands = this.#commandRegistry
123
+ .getGroupCommands()
124
+ .filter((command) => !command.disableGenericHelpDisplay);
125
+ const subCommands = this.#commandRegistry
126
+ .getSubCommands()
127
+ .filter((command) => !command.disableGenericHelpDisplay);
128
+ const helpSections = [];
129
+ helpSections.push({
130
+ title: "Usage",
131
+ helpEntries: [
132
+ {
133
+ syntax: getMultiCommandAppSyntax(context, globalModifierCommands, globalCommands, groupCommands, subCommands),
134
+ },
135
+ ],
136
+ });
137
+ helpSections.push(...this.#getGenericHelpSections(context, globalModifierCommands, globalCommands, groupCommands, subCommands));
138
+ await printHelpSections(printerService, tableGeneratorService, helpSections);
139
+ }
140
+ async printUsageHelp(context, commandName) {
141
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID);
142
+ const tableGeneratorService = context.getServiceById(TABLE_GENERATOR_SERVICE_ID);
143
+ const groupCommands = this.#commandRegistry
144
+ .getGroupCommands()
145
+ .filter((command) => !command.disableGenericHelpDisplay);
146
+ const subCommands = this.#commandRegistry
147
+ .getSubCommands()
148
+ .filter((command) => !command.disableGenericHelpDisplay);
149
+ // find sub-command or group sub-command
150
+ let subCommand = this.#commandRegistry.getSubCommandByName(commandName);
151
+ let groupCommand;
152
+ if (subCommand === undefined) {
153
+ const result = this.#commandRegistry.getGroupCommandAndMemberSubCommandByJoinedName(commandName);
154
+ if (result !== undefined) {
155
+ groupCommand = result.groupCommand;
156
+ subCommand = result.command;
157
+ }
158
+ }
159
+ if (subCommand === undefined) {
160
+ await printerService.print(`Unknown command: ${printerService.red(commandName)}\n\n`, Icon.FAILURE);
161
+ // look for other possible matches
162
+ const possibleCommandNames = findPossibleCommandNames(commandName, groupCommands, subCommands);
163
+ if (possibleCommandNames.length > 0) {
164
+ await printerService.print(`Possible matches: ${possibleCommandNames.join(", ")}\n\n`, Icon.INFORMATION);
165
+ }
166
+ await this.printGenericHelp(context);
167
+ return;
168
+ }
169
+ // display command help
170
+ const name = groupCommand === undefined ? subCommand.name : `${groupCommand.name}:${subCommand.name}`;
171
+ const helpSections = [];
172
+ if (subCommand.description !== undefined && subCommand.description.length > 0) {
173
+ helpSections.push({
174
+ title: "Command",
175
+ helpEntries: [
176
+ {
177
+ syntax: subCommand.name,
178
+ description: subCommand.description,
179
+ },
180
+ ],
181
+ });
182
+ }
183
+ helpSections.push({
184
+ title: "Usage",
185
+ helpEntries: [
186
+ {
187
+ syntax: `${context.cliConfig.name}${name.length > 0 ? ` ${name}` : ""}${getSubCommandArgumentsSyntax(subCommand)}`,
188
+ },
189
+ ],
190
+ });
191
+ helpSections.push(...getCommandArgsHelpSections(context.cliConfig, this.#includeEnvVars, subCommand, false));
192
+ helpSections.push(...getCommandExamplesHelpSections(printerService, context, subCommand));
193
+ await printHelpSections(printerService, tableGeneratorService, helpSections);
194
+ }
195
+ }
196
+ /**
197
+ * Implementation of multi-command CLI help available via `myCli --help`, `myCli -h`, `myCli --help <command>` or `myCli -h <command>`.
198
+ */
199
+ export class MultiCommandCliHelpGlobalCommand extends MultiCommandCliAbstractHelpCommand {
200
+ shortAlias = "h";
201
+ argument = {
202
+ name: "command",
203
+ type: ArgumentValueTypeName.STRING,
204
+ isOptional: true,
205
+ };
206
+ async execute(context, argumentValue) {
207
+ const commandName = argumentValue;
208
+ if (commandName !== undefined) {
209
+ await this.printUsageHelp(context, commandName);
210
+ }
211
+ else {
212
+ await this.printGenericHelp(context);
213
+ }
214
+ }
215
+ }
216
+ /**
217
+ * Implementation of multi-command CLI help available via `myCli help` or `myCli help <command>`.
218
+ */
219
+ export class MultiCommandCliHelpSubCommand extends MultiCommandCliAbstractHelpCommand {
220
+ options = [];
221
+ positionals = [
222
+ {
223
+ name: "command",
224
+ type: ArgumentValueTypeName.STRING,
225
+ isVarargOptional: true,
226
+ description: "Display help for the specific <command>",
227
+ },
228
+ ];
229
+ async execute(context, argumentValues) {
230
+ const commandName = argumentValues["command"];
231
+ if (commandName !== undefined) {
232
+ await this.printUsageHelp(context, commandName);
233
+ }
234
+ else {
235
+ await this.printGenericHelp(context);
236
+ }
237
+ }
238
+ }
@@ -0,0 +1,104 @@
1
+ import { getCommandArgsHelpSections, getCommandExamplesHelpSections, getGlobalArgumentHelpEntry, getSubCommandArgumentsSyntax, printHelpSections, } from "../util/helpHelper.js";
2
+ import { PRINTER_SERVICE_ID } from "../api/service/core/PrinterService.js";
3
+ import { TABLE_GENERATOR_SERVICE_ID } from "../api/service/core/TableGeneratorService.js";
4
+ /**
5
+ * Provides common implementation for both {@link SingleCommandCliHelpGlobalCommand} and {@link SingleCommandCliHelpSubCommand}.
6
+ */
7
+ class SingleCommandCliAbstractHelpCommand {
8
+ #includeEnvVars;
9
+ #defaultCommand;
10
+ #commandRegistry;
11
+ constructor(includeEnvVars, defaultCommand, commandRegistry) {
12
+ this.#includeEnvVars = includeEnvVars;
13
+ this.#defaultCommand = defaultCommand;
14
+ this.#commandRegistry = commandRegistry;
15
+ }
16
+ name = "help";
17
+ description = "Display application help";
18
+ #getAmalgamatedGenericHelpSection(context, globalModifierCommands, globalCommands, groupCommands, subCommands) {
19
+ const helpSection = {
20
+ title: "Other Arguments",
21
+ helpEntries: [],
22
+ };
23
+ if (globalModifierCommands.length > 0) {
24
+ globalModifierCommands.forEach((globalModifierCommand) => {
25
+ const { syntax, description } = getGlobalArgumentHelpEntry(context.cliConfig, this.#includeEnvVars, globalModifierCommand);
26
+ helpSection.helpEntries.push({
27
+ syntax: `--${globalModifierCommand.name} ${syntax}`,
28
+ description,
29
+ });
30
+ if (globalModifierCommand.shortAlias !== undefined) {
31
+ helpSection.helpEntries.push({
32
+ syntax: `-${globalModifierCommand.shortAlias} ${syntax}`,
33
+ description,
34
+ });
35
+ }
36
+ });
37
+ }
38
+ if (globalCommands.length > 0) {
39
+ globalCommands.forEach((globalCommand) => {
40
+ const { syntax, description } = getGlobalArgumentHelpEntry(context.cliConfig, this.#includeEnvVars, globalCommand);
41
+ helpSection.helpEntries.push({
42
+ syntax: `--${globalCommand.name} ${syntax}`,
43
+ description,
44
+ });
45
+ if (globalCommand.shortAlias !== undefined) {
46
+ helpSection.helpEntries.push({
47
+ syntax: `-${globalCommand.shortAlias} ${syntax}`,
48
+ description,
49
+ });
50
+ }
51
+ });
52
+ }
53
+ groupCommands.forEach((groupCommand) => {
54
+ groupCommand.memberSubCommands.forEach((memberCommand) => {
55
+ helpSection.helpEntries.push({
56
+ syntax: `${groupCommand.name}:${memberCommand.name}`,
57
+ description: memberCommand.description,
58
+ });
59
+ });
60
+ });
61
+ if (subCommands.length > 0) {
62
+ subCommands.forEach((subCommand) => {
63
+ helpSection.helpEntries.push({
64
+ syntax: subCommand.name,
65
+ description: subCommand.description,
66
+ });
67
+ });
68
+ }
69
+ helpSection.helpEntries.sort((a, b) => a.syntax.localeCompare(b.syntax));
70
+ return helpSection;
71
+ }
72
+ async execute(context) {
73
+ const helpSections = [];
74
+ helpSections.push({
75
+ title: "Usage",
76
+ helpEntries: [
77
+ {
78
+ syntax: `${context.cliConfig.name || ""}${getSubCommandArgumentsSyntax(this.#defaultCommand)}`,
79
+ },
80
+ ],
81
+ });
82
+ helpSections.push(...getCommandArgsHelpSections(context.cliConfig, this.#includeEnvVars, this.#defaultCommand, true));
83
+ const globalModifierCommands = this.#commandRegistry.getGlobalModifierCommands();
84
+ const globalCommands = this.#commandRegistry.getGlobalCommands();
85
+ helpSections.push(this.#getAmalgamatedGenericHelpSection(context, globalModifierCommands, globalCommands, [], []));
86
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID);
87
+ const tableGeneratorService = context.getServiceById(TABLE_GENERATOR_SERVICE_ID);
88
+ helpSections.push(...getCommandExamplesHelpSections(printerService, context, this.#defaultCommand));
89
+ await printHelpSections(printerService, tableGeneratorService, helpSections);
90
+ }
91
+ }
92
+ /**
93
+ * Implementation of default command CLI help available via `myCli --help` or `myCli -h`.
94
+ */
95
+ export class SingleCommandCliHelpGlobalCommand extends SingleCommandCliAbstractHelpCommand {
96
+ shortAlias = "h";
97
+ }
98
+ /**
99
+ * Implementation of default-command CLI help available via `myCli help`.
100
+ */
101
+ export class SingleCommandCliHelpSubCommand extends SingleCommandCliAbstractHelpCommand {
102
+ options = [];
103
+ positionals = [];
104
+ }
@@ -0,0 +1,16 @@
1
+ import { PRINTER_SERVICE_ID } from "../api/service/core/PrinterService.js";
2
+ /**
3
+ * Command printing basic CLI usage.
4
+ */
5
+ export default class UsageCommand {
6
+ name = "usage";
7
+ description = "Show usage information";
8
+ #helpCommand;
9
+ constructor(helpCommand) {
10
+ this.#helpCommand = helpCommand;
11
+ }
12
+ async execute(context) {
13
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID);
14
+ await printerService.print(`${printerService.secondary("Try running:")}\n\n ${printerService.primary(context.cliConfig.name)} --${printerService.primary(this.#helpCommand.name)}\n\n`);
15
+ }
16
+ }
@@ -0,0 +1,13 @@
1
+ import { PRINTER_SERVICE_ID } from "../api/service/core/PrinterService.js";
2
+ /**
3
+ * Implementation of a {@link GlobalCommand} which outputs the version of the CLI.
4
+ */
5
+ export default class VersionCommand {
6
+ name = "version";
7
+ description = "Show version information";
8
+ shortAlias = "v";
9
+ async execute(context) {
10
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID);
11
+ await printerService.print(`${context.cliConfig.version}\n`);
12
+ }
13
+ }
@@ -0,0 +1,61 @@
1
+ import process from "node:process";
2
+ import path from "node:path";
3
+ import DefaultRuntimeCLI from "./cli/DefaultRuntimeCLI.js";
4
+ import DynamicPluginRuntimeCLI from "./cli/DynamicPluginRuntimeCLI.js";
5
+ export async function launchSingleCommandCLI(command, description, name, version, serviceProviders, options) {
6
+ if (!name) {
7
+ name = path.basename(process.execPath);
8
+ }
9
+ const cliConfig = {
10
+ description,
11
+ name,
12
+ version: version || "N/A",
13
+ };
14
+ const mergedOptions = {
15
+ ...options,
16
+ validateAllCommands: (options?.validateAllCommands ?? false) ||
17
+ process.env.DYNAMIC_CLI_FRAMEWORK_VALIDATE_ALL !== undefined,
18
+ };
19
+ const cli = new DefaultRuntimeCLI(cliConfig, mergedOptions);
20
+ cli.addCommand(command);
21
+ serviceProviders?.forEach((service) => cli.addServiceProvider(service));
22
+ return await cli.run();
23
+ }
24
+ export async function launchMultiCommandCLI(commands, description, name, version, serviceProviders, options) {
25
+ if (!name) {
26
+ name = path.basename(process.execPath);
27
+ }
28
+ const cliConfig = {
29
+ description,
30
+ name,
31
+ version: version || "N/A",
32
+ };
33
+ const mergedOptions = {
34
+ ...options,
35
+ validateAllCommands: (options?.validateAllCommands ?? false) ||
36
+ process.env.DYNAMIC_CLI_FRAMEWORK_VALIDATE_ALL !== undefined,
37
+ };
38
+ const cli = new DefaultRuntimeCLI(cliConfig, mergedOptions);
39
+ commands.forEach((command) => cli.addCommand(command));
40
+ serviceProviders?.forEach((service) => cli.addServiceProvider(service));
41
+ return await cli.run();
42
+ }
43
+ export async function launchDynamicPluginMultiCommandCLI(pluginManager, commands, description, name, version, serviceProviders, options) {
44
+ if (!name) {
45
+ name = path.basename(process.execPath);
46
+ }
47
+ const cliConfig = {
48
+ description,
49
+ name,
50
+ version: version || "N/A",
51
+ };
52
+ const mergedOptions = {
53
+ ...options,
54
+ validateAllCommands: (options?.validateAllCommands ?? false) ||
55
+ process.env.DYNAMIC_CLI_FRAMEWORK_VALIDATE_ALL !== undefined,
56
+ };
57
+ const cli = new DynamicPluginRuntimeCLI(cliConfig, pluginManager, mergedOptions);
58
+ commands.forEach((command) => cli.addCommand(command));
59
+ serviceProviders?.forEach((service) => cli.addServiceProvider(service));
60
+ return await cli.run();
61
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Default implementation of a {@link Context}.
3
+ */
4
+ export default class DefaultContext {
5
+ cliConfig;
6
+ #serviceInstancesById = new Map();
7
+ constructor(cliConfig) {
8
+ this.cliConfig = cliConfig;
9
+ }
10
+ addServiceInstance(id, serviceInstance) {
11
+ if (this.#serviceInstancesById.has(id)) {
12
+ throw new Error(`Service ID: ${id} duplicates the ID of an existing service`);
13
+ }
14
+ this.#serviceInstancesById.set(id, serviceInstance);
15
+ }
16
+ getServiceById(id) {
17
+ if (!this.#serviceInstancesById.has(id)) {
18
+ throw new Error(`Service with ID: ${id} does not exist`);
19
+ }
20
+ return this.#serviceInstancesById.get(id);
21
+ }
22
+ doesServiceExist(id) {
23
+ return this.#serviceInstancesById.has(id);
24
+ }
25
+ }
@@ -0,0 +1,3 @@
1
+ export function isComplexOption(argument) {
2
+ return argument.properties !== undefined;
3
+ }
@@ -0,0 +1,12 @@
1
+ export function isGroupCommand(command) {
2
+ return command.memberSubCommands !== undefined;
3
+ }
4
+ export function isSubCommand(command) {
5
+ return command.options !== undefined;
6
+ }
7
+ export function isGlobalModifierCommand(command) {
8
+ return command.executePriority !== undefined;
9
+ }
10
+ export function isGlobalCommand(command) {
11
+ return !isGroupCommand(command) && !isSubCommand(command) && !isGlobalModifierCommand(command);
12
+ }