@flowscripter/dynamic-cli-framework 1.7.2 → 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 (379) 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 -105710
  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.d.ts +5 -0
  19. package/dist/src/api/command/Command.d.ts.map +1 -1
  20. package/dist/src/api/command/Command.js +0 -0
  21. package/dist/src/api/command/GlobalCommand.js +0 -0
  22. package/dist/src/api/command/GlobalModifierCommand.js +0 -0
  23. package/dist/src/api/command/GroupCommand.js +0 -0
  24. package/dist/src/api/command/SubCommand.js +0 -0
  25. package/dist/src/api/command/UsageExample.js +0 -0
  26. package/dist/src/api/plugin/CLIPlugin.js +2 -0
  27. package/dist/src/api/plugin/CommandFactory.js +7 -0
  28. package/dist/src/api/plugin/ServiceProviderFactory.js +7 -0
  29. package/dist/src/api/plugin/createCLIPlugin.js +30 -0
  30. package/dist/src/api/service/ServiceProvider.js +0 -0
  31. package/dist/src/api/service/core/ArgumentPrompterService.js +1 -0
  32. package/dist/src/api/service/core/AsciiBannerGeneratorService.js +1 -0
  33. package/dist/src/api/service/core/CompletionService.js +8 -0
  34. package/dist/src/api/service/core/DataDumpGeneratorService.js +7 -0
  35. package/dist/src/api/service/core/ImagePrinterService.js +1 -0
  36. package/dist/src/api/service/core/KeyValueService.js +7 -0
  37. package/dist/src/api/service/core/PluginService.js +6 -0
  38. package/dist/src/api/service/core/PrettyPrinterService.js +1 -0
  39. package/dist/src/api/service/core/PrinterService.js +42 -0
  40. package/dist/src/api/service/core/PrompterService.js +10 -0
  41. package/dist/src/api/service/core/SecretService.js +0 -0
  42. package/dist/src/api/service/core/ShutdownService.js +1 -0
  43. package/dist/src/api/service/core/SyntaxHighlighterService.js +1 -0
  44. package/dist/src/api/service/core/Table.js +49 -0
  45. package/dist/src/api/service/core/TableGeneratorService.d.ts +1 -0
  46. package/dist/src/api/service/core/TableGeneratorService.d.ts.map +1 -1
  47. package/dist/src/api/service/core/TableGeneratorService.js +7 -0
  48. package/dist/src/api/service/core/TreePrinterService.js +1 -0
  49. package/dist/src/cli/BaseCLI.d.ts.map +1 -1
  50. package/dist/src/cli/BaseCLI.js +233 -0
  51. package/dist/src/cli/DefaultRuntimeCLI.d.ts.map +1 -1
  52. package/dist/src/cli/DefaultRuntimeCLI.js +20 -0
  53. package/dist/src/cli/DynamicPluginRuntimeCLI.js +50 -0
  54. package/dist/src/command/MultiCommandCliHelpCommand.d.ts.map +1 -1
  55. package/dist/src/command/MultiCommandCliHelpCommand.js +238 -0
  56. package/dist/src/command/SingleCommandCliHelpCommand.js +104 -0
  57. package/dist/src/command/UsageCommand.js +16 -0
  58. package/dist/src/command/VersionCommand.js +13 -0
  59. package/dist/src/launcher.js +61 -0
  60. package/dist/src/runtime/DefaultContext.js +25 -0
  61. package/dist/src/runtime/argument/ArgumentTypeGuards.js +3 -0
  62. package/dist/src/runtime/command/CommandTypeGuards.js +12 -0
  63. package/dist/src/runtime/command/CommandValidator.js +371 -0
  64. package/dist/src/runtime/parser.js +105 -0
  65. package/dist/src/runtime/registry/CommandRegistry.js +0 -0
  66. package/dist/src/runtime/registry/DefaultCommandRegistry.js +190 -0
  67. package/dist/src/runtime/registry/DefaultServiceProviderRegistry.js +20 -0
  68. package/dist/src/runtime/registry/ServiceProviderRegistry.js +0 -0
  69. package/dist/src/runtime/runner.js +507 -0
  70. package/dist/src/runtime/scanner.js +244 -0
  71. package/dist/src/runtime/values/ValuePopulationResult.js +0 -0
  72. package/dist/src/runtime/values/argumentValueMerge.js +122 -0
  73. package/dist/src/runtime/values/argumentValueValidation.js +505 -0
  74. package/dist/src/runtime/values/globalCommandValuePopulation.js +67 -0
  75. package/dist/src/runtime/values/subCommandValuePopulation.js +549 -0
  76. package/dist/src/service/argumentPrompter/ArgumentPrompterServiceProvider.js +19 -0
  77. package/dist/src/service/argumentPrompter/DefaultArgumentPrompterService.js +197 -0
  78. package/dist/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.js +28 -0
  79. package/dist/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.js +233 -0
  80. package/dist/src/service/asciiBannerGenerator/standard.flf.json +3 -0
  81. package/dist/src/service/banner/BannerServiceProvider.js +60 -0
  82. package/dist/src/service/banner/command/NoBannerCommand.js +24 -0
  83. package/dist/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.js +51 -0
  84. package/dist/src/service/chiselAsciiBannerGenerator/chisel.flf.json +3 -0
  85. package/dist/src/service/completion/CompletionServiceProvider.d.ts +2 -1
  86. package/dist/src/service/completion/CompletionServiceProvider.d.ts.map +1 -1
  87. package/dist/src/service/completion/CompletionServiceProvider.js +160 -0
  88. package/dist/src/service/completion/DefaultCompletionService.d.ts.map +1 -1
  89. package/dist/src/service/completion/DefaultCompletionService.js +279 -0
  90. package/dist/src/service/completion/command/CompletionCompleteSubCommand.d.ts +15 -0
  91. package/dist/src/service/completion/command/CompletionCompleteSubCommand.d.ts.map +1 -0
  92. package/dist/src/service/completion/command/CompletionCompleteSubCommand.js +37 -0
  93. package/dist/src/service/completion/command/CompletionGroupCommand.d.ts +14 -0
  94. package/dist/src/service/completion/command/CompletionGroupCommand.d.ts.map +1 -0
  95. package/dist/src/service/completion/command/CompletionGroupCommand.js +10 -0
  96. package/dist/src/service/completion/command/CompletionIntegrationSubCommand.d.ts +14 -0
  97. package/dist/src/service/completion/command/CompletionIntegrationSubCommand.d.ts.map +1 -0
  98. package/dist/src/service/completion/command/CompletionIntegrationSubCommand.js +67 -0
  99. package/dist/src/service/completion/shell/ShellHandler.js +0 -0
  100. package/dist/src/service/completion/shell/bash.js +39 -0
  101. package/dist/src/service/completion/shell/fish.js +35 -0
  102. package/dist/src/service/completion/shell/powershell.js +51 -0
  103. package/dist/src/service/completion/shell/zsh.js +42 -0
  104. package/dist/src/service/configuration/ConfigurationServiceProvider.js +482 -0
  105. package/dist/src/service/configuration/DefaultKeyValueService.js +80 -0
  106. package/dist/src/service/configuration/DefaultSecretService.js +60 -0
  107. package/dist/src/service/configuration/command/ConfigCommand.js +24 -0
  108. package/dist/src/service/configuration/command/DumpConfigCommand.js +18 -0
  109. package/dist/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.js +24 -0
  110. package/dist/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.js +59 -0
  111. package/dist/src/service/imagePrinter/DefaultImagePrinterService.js +10 -0
  112. package/dist/src/service/imagePrinter/ImagePrinterServiceProvider.js +20 -0
  113. package/dist/src/service/plugin/DefaultPluginService.js +21 -0
  114. package/dist/src/service/plugin/DefaultPluginServiceProvider.d.ts +1 -1
  115. package/dist/src/service/plugin/DefaultPluginServiceProvider.d.ts.map +1 -1
  116. package/dist/src/service/plugin/DefaultPluginServiceProvider.js +21 -0
  117. package/dist/src/service/plugin/command/PluginAddSubCommand.d.ts +17 -0
  118. package/dist/src/service/plugin/command/PluginAddSubCommand.d.ts.map +1 -0
  119. package/dist/src/service/plugin/command/PluginAddSubCommand.js +49 -0
  120. package/dist/src/service/plugin/command/PluginGroupCommand.d.ts +12 -0
  121. package/dist/src/service/plugin/command/PluginGroupCommand.d.ts.map +1 -0
  122. package/dist/src/service/plugin/command/PluginGroupCommand.js +21 -0
  123. package/dist/src/service/plugin/command/PluginListSubCommand.d.ts +12 -0
  124. package/dist/src/service/plugin/command/PluginListSubCommand.d.ts.map +1 -0
  125. package/dist/src/service/plugin/command/PluginListSubCommand.js +25 -0
  126. package/dist/src/service/plugin/command/PluginRemoveSubCommand.d.ts +17 -0
  127. package/dist/src/service/plugin/command/PluginRemoveSubCommand.d.ts.map +1 -0
  128. package/dist/src/service/plugin/command/PluginRemoveSubCommand.js +24 -0
  129. package/dist/src/service/plugin/command/PluginSearchSubCommand.d.ts +18 -0
  130. package/dist/src/service/plugin/command/PluginSearchSubCommand.d.ts.map +1 -0
  131. package/dist/src/service/plugin/command/PluginSearchSubCommand.js +34 -0
  132. package/dist/src/service/plugin/command/PluginUpgradeSubCommand.d.ts +12 -0
  133. package/dist/src/service/plugin/command/PluginUpgradeSubCommand.d.ts.map +1 -0
  134. package/dist/src/service/plugin/command/PluginUpgradeSubCommand.js +25 -0
  135. package/dist/src/service/plugin/command/getPluginId.d.ts +3 -0
  136. package/dist/src/service/plugin/command/getPluginId.d.ts.map +1 -0
  137. package/dist/src/service/plugin/command/getPluginId.js +3 -0
  138. package/dist/src/service/prettyPrinter/DefaultPrettyPrinterService.js +45 -0
  139. package/dist/src/service/prettyPrinter/PrettyPrinterServiceProvider.js +28 -0
  140. package/dist/src/service/printer/DefaultPrinterService.js +250 -0
  141. package/dist/src/service/printer/PrinterServiceProvider.js +43 -0
  142. package/dist/src/service/printer/command/DarkModeCommand.js +24 -0
  143. package/dist/src/service/printer/command/LogLevelCommand.js +41 -0
  144. package/dist/src/service/printer/command/NoColorCommand.js +24 -0
  145. package/dist/src/service/printer/command/NoHyperlinksCommand.js +21 -0
  146. package/dist/src/service/printer/terminal/Color.js +15 -0
  147. package/dist/src/service/printer/terminal/Progress.js +271 -0
  148. package/dist/src/service/printer/terminal/Spinner.js +83 -0
  149. package/dist/src/service/printer/terminal/Theme.js +26 -0
  150. package/dist/src/service/prompter/DefaultPrompterService.js +52 -0
  151. package/dist/src/service/prompter/PrompterServiceProvider.js +20 -0
  152. package/dist/src/service/prompter/command/NoPromptCommand.js +21 -0
  153. package/dist/src/service/prompter/prompt/PromptContext.js +22 -0
  154. package/dist/src/service/prompter/prompt/promptAcknowledge.js +19 -0
  155. package/dist/src/service/prompter/prompt/promptMultiSelect.js +74 -0
  156. package/dist/src/service/prompter/prompt/promptOpenUrl.js +70 -0
  157. package/dist/src/service/prompter/prompt/promptSingleSelect.js +73 -0
  158. package/dist/src/service/prompter/prompt/promptText.js +75 -0
  159. package/dist/src/service/prompter/prompt/promptToggle.js +21 -0
  160. package/dist/src/service/shutdown/DefaultShutdownService.js +16 -0
  161. package/dist/src/service/shutdown/ShutdownServiceProvider.js +60 -0
  162. package/dist/src/service/shutdown/ShutdownState.js +5 -0
  163. package/dist/src/service/syntaxHighlighter/DefaultSyntaxHighlighterService.js +54 -0
  164. package/dist/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.js +32 -0
  165. package/dist/src/service/tableGenerator/DefaultTableGeneratorService.d.ts +3 -1
  166. package/dist/src/service/tableGenerator/DefaultTableGeneratorService.d.ts.map +1 -1
  167. package/dist/src/service/tableGenerator/DefaultTableGeneratorService.js +344 -0
  168. package/dist/src/service/tableGenerator/TableGeneratorServiceProvider.js +26 -0
  169. package/dist/src/service/treePrinter/DefaultTreePrinterService.js +35 -0
  170. package/dist/src/service/treePrinter/TreePrinterServiceProvider.js +24 -0
  171. package/dist/src/terminal/Ansi.js +23 -0
  172. package/dist/src/terminal/ImageRenderer.js +164 -0
  173. package/dist/src/terminal/KeyReader.js +13 -0
  174. package/dist/src/terminal/PngDecoder.js +115 -0
  175. package/dist/src/terminal/Styler.js +0 -0
  176. package/dist/src/terminal/Terminal.js +0 -0
  177. package/dist/src/terminal/TtyKeyReader.js +87 -0
  178. package/dist/src/terminal/TtyStyler.js +55 -0
  179. package/dist/src/terminal/TtyTerminal.js +52 -0
  180. package/dist/src/terminal/supportsHyperlinks.d.ts.map +1 -1
  181. package/dist/src/terminal/supportsHyperlinks.js +95 -0
  182. package/dist/src/util/configHelper.js +61 -0
  183. package/dist/src/util/envVarHelper.js +216 -0
  184. package/dist/src/util/helpHelper.d.ts.map +1 -1
  185. package/dist/src/util/helpHelper.js +497 -0
  186. package/dist/src/util/logger.js +81 -0
  187. package/dist/src/util/runnerHelper.d.ts +1 -0
  188. package/dist/src/util/runnerHelper.d.ts.map +1 -1
  189. package/dist/src/util/runnerHelper.js +80 -0
  190. package/package.json +3 -3
  191. package/src/api/command/Command.ts +6 -0
  192. package/src/api/service/core/TableGeneratorService.ts +1 -0
  193. package/src/cli/BaseCLI.ts +6 -18
  194. package/src/cli/DefaultRuntimeCLI.ts +0 -4
  195. package/src/command/MultiCommandCliHelpCommand.ts +23 -7
  196. package/src/service/completion/CompletionServiceProvider.ts +16 -2
  197. package/src/service/completion/DefaultCompletionService.ts +14 -0
  198. package/src/service/completion/command/CompletionCompleteSubCommand.ts +59 -0
  199. package/src/service/completion/command/CompletionGroupCommand.ts +21 -0
  200. package/src/{command/CompletionCommand.ts → service/completion/command/CompletionIntegrationSubCommand.ts} +12 -72
  201. package/src/service/completion/shell/bash.ts +1 -1
  202. package/src/service/completion/shell/fish.ts +1 -1
  203. package/src/service/completion/shell/powershell.ts +1 -1
  204. package/src/service/completion/shell/zsh.ts +1 -1
  205. package/src/service/plugin/DefaultPluginServiceProvider.ts +2 -2
  206. package/src/service/plugin/command/PluginAddSubCommand.ts +64 -0
  207. package/src/service/plugin/command/PluginGroupCommand.ts +27 -0
  208. package/src/service/plugin/command/PluginListSubCommand.ts +33 -0
  209. package/src/service/plugin/command/PluginRemoveSubCommand.ts +32 -0
  210. package/src/service/plugin/command/PluginSearchSubCommand.ts +42 -0
  211. package/src/service/plugin/command/PluginUpgradeSubCommand.ts +36 -0
  212. package/src/service/plugin/command/getPluginId.ts +5 -0
  213. package/src/service/tableGenerator/DefaultTableGeneratorService.ts +7 -2
  214. package/src/terminal/supportsHyperlinks.ts +22 -0
  215. package/src/util/helpHelper.ts +7 -6
  216. package/src/util/runnerHelper.ts +14 -2
  217. package/dist/src/command/CompletionCommand.d.ts +0 -31
  218. package/dist/src/command/CompletionCommand.d.ts.map +0 -1
  219. package/dist/src/command/PluginCommand.d.ts +0 -67
  220. package/dist/src/command/PluginCommand.d.ts.map +0 -1
  221. package/dist/tests/cli/BaseCLI.test.d.ts +0 -2
  222. package/dist/tests/cli/BaseCLI.test.d.ts.map +0 -1
  223. package/dist/tests/cli/DynamicPluginRuntimeCLI.test.d.ts +0 -2
  224. package/dist/tests/cli/DynamicPluginRuntimeCLI.test.d.ts.map +0 -1
  225. package/dist/tests/command/CompletionCommand.test.d.ts +0 -2
  226. package/dist/tests/command/CompletionCommand.test.d.ts.map +0 -1
  227. package/dist/tests/command/MultiCommandCliHelpCommand.test.d.ts +0 -2
  228. package/dist/tests/command/MultiCommandCliHelpCommand.test.d.ts.map +0 -1
  229. package/dist/tests/command/SingleCommandCliHelpCommand.test.d.ts +0 -2
  230. package/dist/tests/command/SingleCommandCliHelpCommand.test.d.ts.map +0 -1
  231. package/dist/tests/command/UsageCommand.test.d.ts +0 -2
  232. package/dist/tests/command/UsageCommand.test.d.ts.map +0 -1
  233. package/dist/tests/command/VersionCommand.test.d.ts +0 -2
  234. package/dist/tests/command/VersionCommand.test.d.ts.map +0 -1
  235. package/dist/tests/fixtures/CLIConfig.d.ts +0 -3
  236. package/dist/tests/fixtures/CLIConfig.d.ts.map +0 -1
  237. package/dist/tests/fixtures/Command.d.ts +0 -20
  238. package/dist/tests/fixtures/Command.d.ts.map +0 -1
  239. package/dist/tests/fixtures/CommandRegistry.d.ts +0 -4
  240. package/dist/tests/fixtures/CommandRegistry.d.ts.map +0 -1
  241. package/dist/tests/fixtures/ConfigurationServiceProvider.d.ts +0 -10
  242. package/dist/tests/fixtures/ConfigurationServiceProvider.d.ts.map +0 -1
  243. package/dist/tests/fixtures/Context.d.ts +0 -4
  244. package/dist/tests/fixtures/Context.d.ts.map +0 -1
  245. package/dist/tests/fixtures/ServiceProviderRegistry.d.ts +0 -4
  246. package/dist/tests/fixtures/ServiceProviderRegistry.d.ts.map +0 -1
  247. package/dist/tests/fixtures/StreamString.d.ts +0 -10
  248. package/dist/tests/fixtures/StreamString.d.ts.map +0 -1
  249. package/dist/tests/fixtures/prettierPluginFoo.d.ts +0 -4
  250. package/dist/tests/fixtures/prettierPluginFoo.d.ts.map +0 -1
  251. package/dist/tests/fixtures/util.d.ts +0 -8
  252. package/dist/tests/fixtures/util.d.ts.map +0 -1
  253. package/dist/tests/runtime/DefaultContext.test.d.ts +0 -2
  254. package/dist/tests/runtime/DefaultContext.test.d.ts.map +0 -1
  255. package/dist/tests/runtime/argument/ArgumentTypeGuards.test.d.ts +0 -2
  256. package/dist/tests/runtime/argument/ArgumentTypeGuards.test.d.ts.map +0 -1
  257. package/dist/tests/runtime/command/CommandTypeGuards.test.d.ts +0 -2
  258. package/dist/tests/runtime/command/CommandTypeGuards.test.d.ts.map +0 -1
  259. package/dist/tests/runtime/command/CommandValidator.test.d.ts +0 -2
  260. package/dist/tests/runtime/command/CommandValidator.test.d.ts.map +0 -1
  261. package/dist/tests/runtime/parser.test.d.ts +0 -2
  262. package/dist/tests/runtime/parser.test.d.ts.map +0 -1
  263. package/dist/tests/runtime/registry/DefaultCommandRegistry.test.d.ts +0 -2
  264. package/dist/tests/runtime/registry/DefaultCommandRegistry.test.d.ts.map +0 -1
  265. package/dist/tests/runtime/registry/DefaultServiceProviderRegistry.test.d.ts +0 -2
  266. package/dist/tests/runtime/registry/DefaultServiceProviderRegistry.test.d.ts.map +0 -1
  267. package/dist/tests/runtime/runner.test.d.ts +0 -2
  268. package/dist/tests/runtime/runner.test.d.ts.map +0 -1
  269. package/dist/tests/runtime/scanner.test.d.ts +0 -2
  270. package/dist/tests/runtime/scanner.test.d.ts.map +0 -1
  271. package/dist/tests/runtime/values/argumentValueMerge.test.d.ts +0 -2
  272. package/dist/tests/runtime/values/argumentValueMerge.test.d.ts.map +0 -1
  273. package/dist/tests/runtime/values/argumentValueValidation.test.d.ts +0 -2
  274. package/dist/tests/runtime/values/argumentValueValidation.test.d.ts.map +0 -1
  275. package/dist/tests/runtime/values/globalCommandValuePopulation.test.d.ts +0 -2
  276. package/dist/tests/runtime/values/globalCommandValuePopulation.test.d.ts.map +0 -1
  277. package/dist/tests/runtime/values/subCommandValuePopulation.test.d.ts +0 -2
  278. package/dist/tests/runtime/values/subCommandValuePopulation.test.d.ts.map +0 -1
  279. package/dist/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.d.ts +0 -2
  280. package/dist/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.d.ts.map +0 -1
  281. package/dist/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.d.ts +0 -2
  282. package/dist/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.d.ts.map +0 -1
  283. package/dist/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.d.ts +0 -2
  284. package/dist/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.d.ts.map +0 -1
  285. package/dist/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.d.ts +0 -2
  286. package/dist/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.d.ts.map +0 -1
  287. package/dist/tests/service/banner/BannerServiceProvider.test.d.ts +0 -2
  288. package/dist/tests/service/banner/BannerServiceProvider.test.d.ts.map +0 -1
  289. package/dist/tests/service/banner/command/NoBannerCommand.test.d.ts +0 -2
  290. package/dist/tests/service/banner/command/NoBannerCommand.test.d.ts.map +0 -1
  291. package/dist/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.d.ts +0 -2
  292. package/dist/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.d.ts.map +0 -1
  293. package/dist/tests/service/completion/CompletionServiceProvider.test.d.ts +0 -2
  294. package/dist/tests/service/completion/CompletionServiceProvider.test.d.ts.map +0 -1
  295. package/dist/tests/service/completion/DefaultCompletionService.test.d.ts +0 -2
  296. package/dist/tests/service/completion/DefaultCompletionService.test.d.ts.map +0 -1
  297. package/dist/tests/service/completion/shell/bash.test.d.ts +0 -2
  298. package/dist/tests/service/completion/shell/bash.test.d.ts.map +0 -1
  299. package/dist/tests/service/completion/shell/fish.test.d.ts +0 -2
  300. package/dist/tests/service/completion/shell/fish.test.d.ts.map +0 -1
  301. package/dist/tests/service/completion/shell/powershell.test.d.ts +0 -2
  302. package/dist/tests/service/completion/shell/powershell.test.d.ts.map +0 -1
  303. package/dist/tests/service/completion/shell/zsh.test.d.ts +0 -2
  304. package/dist/tests/service/completion/shell/zsh.test.d.ts.map +0 -1
  305. package/dist/tests/service/configuration/ConfigurationServiceProvider.test.d.ts +0 -2
  306. package/dist/tests/service/configuration/ConfigurationServiceProvider.test.d.ts.map +0 -1
  307. package/dist/tests/service/configuration/DefaultKeyValueService.test.d.ts +0 -2
  308. package/dist/tests/service/configuration/DefaultKeyValueService.test.d.ts.map +0 -1
  309. package/dist/tests/service/configuration/DefaultSecretService.test.d.ts +0 -2
  310. package/dist/tests/service/configuration/DefaultSecretService.test.d.ts.map +0 -1
  311. package/dist/tests/service/configuration/command/ConfigCommand.test.d.ts +0 -2
  312. package/dist/tests/service/configuration/command/ConfigCommand.test.d.ts.map +0 -1
  313. package/dist/tests/service/configuration/command/DumpConfigCommand.test.d.ts +0 -2
  314. package/dist/tests/service/configuration/command/DumpConfigCommand.test.d.ts.map +0 -1
  315. package/dist/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.d.ts +0 -2
  316. package/dist/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.d.ts.map +0 -1
  317. package/dist/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.d.ts +0 -2
  318. package/dist/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.d.ts.map +0 -1
  319. package/dist/tests/service/imagePrinter/DefaultImagePrinterService.test.d.ts +0 -2
  320. package/dist/tests/service/imagePrinter/DefaultImagePrinterService.test.d.ts.map +0 -1
  321. package/dist/tests/service/imagePrinter/ImagePrinterServiceProvider.test.d.ts +0 -2
  322. package/dist/tests/service/imagePrinter/ImagePrinterServiceProvider.test.d.ts.map +0 -1
  323. package/dist/tests/service/plugin/DefaultPluginServiceProvider.test.d.ts +0 -2
  324. package/dist/tests/service/plugin/DefaultPluginServiceProvider.test.d.ts.map +0 -1
  325. package/dist/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.d.ts +0 -2
  326. package/dist/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.d.ts.map +0 -1
  327. package/dist/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.d.ts +0 -2
  328. package/dist/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.d.ts.map +0 -1
  329. package/dist/tests/service/printer/DefaultPrinterService.test.d.ts +0 -2
  330. package/dist/tests/service/printer/DefaultPrinterService.test.d.ts.map +0 -1
  331. package/dist/tests/service/printer/PrinterServiceProvider.test.d.ts +0 -2
  332. package/dist/tests/service/printer/PrinterServiceProvider.test.d.ts.map +0 -1
  333. package/dist/tests/service/printer/command/DarkModeCommand.test.d.ts +0 -2
  334. package/dist/tests/service/printer/command/DarkModeCommand.test.d.ts.map +0 -1
  335. package/dist/tests/service/printer/command/LogLevelCommand.test.d.ts +0 -2
  336. package/dist/tests/service/printer/command/LogLevelCommand.test.d.ts.map +0 -1
  337. package/dist/tests/service/printer/command/NoColorCommand.test.d.ts +0 -2
  338. package/dist/tests/service/printer/command/NoColorCommand.test.d.ts.map +0 -1
  339. package/dist/tests/service/printer/command/NoHyperlinksCommand.test.d.ts +0 -2
  340. package/dist/tests/service/printer/command/NoHyperlinksCommand.test.d.ts.map +0 -1
  341. package/dist/tests/service/printer/terminal/Progress.test.d.ts +0 -2
  342. package/dist/tests/service/printer/terminal/Progress.test.d.ts.map +0 -1
  343. package/dist/tests/service/printer/terminal/Spinner.test.d.ts +0 -2
  344. package/dist/tests/service/printer/terminal/Spinner.test.d.ts.map +0 -1
  345. package/dist/tests/service/prompter/DefaultPrompterService.test.d.ts +0 -2
  346. package/dist/tests/service/prompter/DefaultPrompterService.test.d.ts.map +0 -1
  347. package/dist/tests/service/prompter/PrompterServiceProvider.test.d.ts +0 -2
  348. package/dist/tests/service/prompter/PrompterServiceProvider.test.d.ts.map +0 -1
  349. package/dist/tests/service/prompter/command/NoPromptCommand.test.d.ts +0 -2
  350. package/dist/tests/service/prompter/command/NoPromptCommand.test.d.ts.map +0 -1
  351. package/dist/tests/service/prompter/prompt/PromptContext.test.d.ts +0 -2
  352. package/dist/tests/service/prompter/prompt/PromptContext.test.d.ts.map +0 -1
  353. package/dist/tests/service/shutdown/ShutdownServiceProvider.test.d.ts +0 -2
  354. package/dist/tests/service/shutdown/ShutdownServiceProvider.test.d.ts.map +0 -1
  355. package/dist/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.d.ts +0 -2
  356. package/dist/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.d.ts.map +0 -1
  357. package/dist/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.d.ts +0 -2
  358. package/dist/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.d.ts.map +0 -1
  359. package/dist/tests/service/tableGenerator/DefaultTableGeneratorService.test.d.ts +0 -2
  360. package/dist/tests/service/tableGenerator/DefaultTableGeneratorService.test.d.ts.map +0 -1
  361. package/dist/tests/service/tableGenerator/TableGeneratorServiceProvider.test.d.ts +0 -2
  362. package/dist/tests/service/tableGenerator/TableGeneratorServiceProvider.test.d.ts.map +0 -1
  363. package/dist/tests/service/treePrinter/DefaultTreePrinterService.test.d.ts +0 -2
  364. package/dist/tests/service/treePrinter/DefaultTreePrinterService.test.d.ts.map +0 -1
  365. package/dist/tests/service/treePrinter/TreePrinterServiceProvider.test.d.ts +0 -2
  366. package/dist/tests/service/treePrinter/TreePrinterServiceProvider.test.d.ts.map +0 -1
  367. package/dist/tests/terminal/ImageRenderer.test.d.ts +0 -2
  368. package/dist/tests/terminal/ImageRenderer.test.d.ts.map +0 -1
  369. package/dist/tests/terminal/PngDecoder.test.d.ts +0 -2
  370. package/dist/tests/terminal/PngDecoder.test.d.ts.map +0 -1
  371. package/dist/tests/terminal/supportsHyperlinks.test.d.ts +0 -2
  372. package/dist/tests/terminal/supportsHyperlinks.test.d.ts.map +0 -1
  373. package/dist/tests/util/configHelper.test.d.ts +0 -2
  374. package/dist/tests/util/configHelper.test.d.ts.map +0 -1
  375. package/dist/tests/util/envVarHelper.test.d.ts +0 -2
  376. package/dist/tests/util/envVarHelper.test.d.ts.map +0 -1
  377. package/dist/tests/util/logger.test.d.ts +0 -2
  378. package/dist/tests/util/logger.test.d.ts.map +0 -1
  379. package/src/command/PluginCommand.ts +0 -197
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/dynamic-cli-framework",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
5
5
  "keywords": [
6
6
  "bun",
@@ -35,7 +35,7 @@
35
35
  "types": "./dist/index.d.ts",
36
36
  "default": "./dist/index.js"
37
37
  },
38
- "./plugin": {
38
+ "./cli-plugin": {
39
39
  "bun": "./cli-plugin.ts",
40
40
  "types": "./dist/cli-plugin.d.ts",
41
41
  "default": "./dist/cli-plugin.js"
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "scripts": {
48
- "build": "bun build index.ts cli-plugin.ts --outdir dist --target bun && tsc -p tsconfig.build.json"
48
+ "build": "tsc -p tsconfig.build.json"
49
49
  },
50
50
  "dependencies": {
51
51
  "@flowscripter/dynamic-plugin-framework": "1.10.1",
@@ -19,4 +19,10 @@ export default interface Command {
19
19
  * default argument values may be sourced using a configuration source provided by the CLI runtime.
20
20
  */
21
21
  readonly enableConfiguration?: boolean;
22
+
23
+ /**
24
+ * Optionally hide the command from generic help listings. The command remains registered and
25
+ * executable, and its own usage help (`help <command>`) is still shown if explicitly requested.
26
+ */
27
+ readonly disableGenericHelpDisplay?: boolean;
22
28
  }
@@ -32,6 +32,7 @@ export interface CellOptions {
32
32
  }
33
33
 
34
34
  export default interface TableGeneratorService {
35
+ createTable(rowCount: number, columnCount: number, options?: TableOptions): Table;
35
36
  render(table: Table): string;
36
37
  }
37
38
 
@@ -33,6 +33,7 @@ import ConfigurationServiceProvider from "../service/configuration/Configuration
33
33
  import PrinterServiceProvider from "../service/printer/PrinterServiceProvider.ts";
34
34
  import TableGeneratorServiceProvider from "../service/tableGenerator/TableGeneratorServiceProvider.ts";
35
35
  import { run } from "../runtime/runner.ts";
36
+ import { printRuntimeError } from "../util/runnerHelper.ts";
36
37
 
37
38
  import { WritableStream } from "node:stream/web";
38
39
  import type Terminal from "../terminal/Terminal.ts";
@@ -50,11 +51,6 @@ import ArgumentPrompterServiceProvider from "../service/argumentPrompter/Argumen
50
51
  import DefaultCompletionService from "../service/completion/DefaultCompletionService.ts";
51
52
  import CompletionServiceProvider from "../service/completion/CompletionServiceProvider.ts";
52
53
  import ImagePrinterServiceProvider from "../service/imagePrinter/ImagePrinterServiceProvider.ts";
53
- import {
54
- CompletionCompleteSubCommand,
55
- CompletionGroupCommand,
56
- CompletionIntegrationSubCommand,
57
- } from "../command/CompletionCommand.ts";
58
54
  const logger = getLogger("BaseCLI");
59
55
 
60
56
  /**
@@ -232,10 +228,11 @@ export default class BaseCLI implements CLI {
232
228
  this.addServiceProvider(new ImagePrinterServiceProvider(55, this.#stdoutTerminal));
233
229
  }
234
230
 
235
- let completionService: DefaultCompletionService | undefined;
236
231
  if (this.#options.completionServiceEnabled) {
237
- completionService = new DefaultCompletionService();
238
- this.addServiceProvider(new CompletionServiceProvider(5, completionService));
232
+ const completionService = new DefaultCompletionService();
233
+ this.addServiceProvider(
234
+ new CompletionServiceProvider(5, completionService, this.#commandRegistry),
235
+ );
239
236
  }
240
237
 
241
238
  const configurationServiceProvider = new ConfigurationServiceProvider(
@@ -302,16 +299,6 @@ export default class BaseCLI implements CLI {
302
299
  // register the version command
303
300
  this.#commandRegistry.addCommand(new VersionCommand());
304
301
 
305
- // register completion commands (need CommandRegistry reference like help commands)
306
- if (completionService) {
307
- completionService.setCommandRegistry(this.#commandRegistry);
308
- const integrationCommand = new CompletionIntegrationSubCommand();
309
- const completeCommand = new CompletionCompleteSubCommand();
310
- this.#commandRegistry.addCommand(
311
- new CompletionGroupCommand(integrationCommand, completeCommand),
312
- );
313
- }
314
-
315
302
  // run...
316
303
  const runResult = await run(
317
304
  args,
@@ -345,6 +332,7 @@ export default class BaseCLI implements CLI {
345
332
  return { runState: RunState.INTERRUPTED };
346
333
  }
347
334
  logger.error("Runtime error: %s", (error as Error).message);
335
+ await printRuntimeError(this.#context, error as Error);
348
336
  return {
349
337
  runState: RunState.RUNTIME_ERROR,
350
338
  error: error as Error,
@@ -1,7 +1,6 @@
1
1
  import process from "node:process";
2
2
  import BaseCLI from "./BaseCLI.ts";
3
3
  import type RunResult from "../api/RunResult.ts";
4
- import { RunState } from "../api/RunResult.ts";
5
4
  import type CLIConfig from "../api/CLIConfig.ts";
6
5
  import type BaseCLIFeatureOptions from "../api/BaseCLIFeatureOptions.ts";
7
6
  import { Writable } from "node:stream";
@@ -35,9 +34,6 @@ export default class DefaultRuntimeCLI extends BaseCLI {
35
34
 
36
35
  override async run(): Promise<RunResult> {
37
36
  const runResult = await super.run(process.argv.slice(2));
38
- if (runResult.runState === RunState.RUNTIME_ERROR) {
39
- console.error(runResult.error);
40
- }
41
37
  process.exit(runResult.runState);
42
38
  }
43
39
  }
@@ -94,11 +94,15 @@ abstract class MultiCommandCliAbstractHelpCommand {
94
94
  );
95
95
  }
96
96
  groupCommands.forEach((groupCommand) => {
97
+ const visibleMemberSubCommands = groupCommand.memberSubCommands.filter(
98
+ (memberCommand) => !memberCommand.disableGenericHelpDisplay,
99
+ );
100
+ if (visibleMemberSubCommands.length === 0) return;
97
101
  const topicSection: HelpSection = {
98
102
  title: `${groupCommand.name.charAt(0).toUpperCase() + groupCommand.name.slice(1)} Commands`,
99
103
  helpEntries: [],
100
104
  };
101
- groupCommand.memberSubCommands.forEach((memberCommand) => {
105
+ visibleMemberSubCommands.forEach((memberCommand) => {
102
106
  topicSection.helpEntries.push({
103
107
  syntax: `${groupCommand.name}:${memberCommand.name}`,
104
108
  description: memberCommand.description,
@@ -166,10 +170,18 @@ abstract class MultiCommandCliAbstractHelpCommand {
166
170
  TABLE_GENERATOR_SERVICE_ID,
167
171
  ) as TableGeneratorService;
168
172
 
169
- const globalModifierCommands = this.#commandRegistry.getGlobalModifierCommands();
170
- const globalCommands = this.#commandRegistry.getGlobalCommands();
171
- const groupCommands = this.#commandRegistry.getGroupCommands();
172
- const subCommands = this.#commandRegistry.getSubCommands();
173
+ const globalModifierCommands = this.#commandRegistry
174
+ .getGlobalModifierCommands()
175
+ .filter((command) => !command.disableGenericHelpDisplay);
176
+ const globalCommands = this.#commandRegistry
177
+ .getGlobalCommands()
178
+ .filter((command) => !command.disableGenericHelpDisplay);
179
+ const groupCommands = this.#commandRegistry
180
+ .getGroupCommands()
181
+ .filter((command) => !command.disableGenericHelpDisplay);
182
+ const subCommands = this.#commandRegistry
183
+ .getSubCommands()
184
+ .filter((command) => !command.disableGenericHelpDisplay);
173
185
  const helpSections: Array<HelpSection> = [];
174
186
  helpSections.push({
175
187
  title: "Usage",
@@ -205,8 +217,12 @@ abstract class MultiCommandCliAbstractHelpCommand {
205
217
  TABLE_GENERATOR_SERVICE_ID,
206
218
  ) as TableGeneratorService;
207
219
 
208
- const groupCommands = this.#commandRegistry.getGroupCommands();
209
- const subCommands = this.#commandRegistry.getSubCommands();
220
+ const groupCommands = this.#commandRegistry
221
+ .getGroupCommands()
222
+ .filter((command) => !command.disableGenericHelpDisplay);
223
+ const subCommands = this.#commandRegistry
224
+ .getSubCommands()
225
+ .filter((command) => !command.disableGenericHelpDisplay);
210
226
 
211
227
  // find sub-command or group sub-command
212
228
  let subCommand = this.#commandRegistry.getSubCommandByName(commandName);
@@ -13,7 +13,11 @@ import { KEY_VALUE_SERVICE_ID } from "../../api/service/core/KeyValueService.ts"
13
13
  import type KeyValueService from "../../api/service/core/KeyValueService.ts";
14
14
  import { Icon, PRINTER_SERVICE_ID } from "../../api/service/core/PrinterService.ts";
15
15
  import type PrinterService from "../../api/service/core/PrinterService.ts";
16
+ import type CommandRegistry from "../../runtime/registry/CommandRegistry.ts";
16
17
  import getLogger from "../../util/logger.ts";
18
+ import { CompletionIntegrationSubCommand } from "./command/CompletionIntegrationSubCommand.ts";
19
+ import { CompletionCompleteSubCommand } from "./command/CompletionCompleteSubCommand.ts";
20
+ import { CompletionGroupCommand } from "./command/CompletionGroupCommand.ts";
17
21
 
18
22
  const logger = getLogger("CompletionServiceProvider");
19
23
 
@@ -23,16 +27,26 @@ export default class CompletionServiceProvider implements ServiceProvider {
23
27
  readonly #completionService: DefaultCompletionService;
24
28
  #cliName = "";
25
29
 
26
- public constructor(servicePriority: number, completionService: DefaultCompletionService) {
30
+ public constructor(
31
+ servicePriority: number,
32
+ completionService: DefaultCompletionService,
33
+ commandRegistry: CommandRegistry,
34
+ ) {
27
35
  this.servicePriority = servicePriority;
28
36
  this.#completionService = completionService;
37
+ this.#completionService.setCommandRegistry(commandRegistry);
29
38
  }
30
39
 
31
40
  public getServiceInfo(cliConfig: CLIConfig): Promise<ServiceInfo> {
32
41
  this.#cliName = cliConfig.name;
33
42
  return Promise.resolve({
34
43
  service: this.#completionService,
35
- commands: [],
44
+ commands: [
45
+ new CompletionGroupCommand(
46
+ new CompletionIntegrationSubCommand(),
47
+ new CompletionCompleteSubCommand(),
48
+ ),
49
+ ],
36
50
  });
37
51
  }
38
52
 
@@ -112,6 +112,20 @@ export default class DefaultCompletionService implements CompletionService {
112
112
  }
113
113
  }
114
114
 
115
+ // Check global command (--name pattern)
116
+ if (commandWord.startsWith("--")) {
117
+ const globalCommandName = commandWord.substring(2);
118
+ const globalCommand = this.#commandRegistry!.getGlobalCommandByName(globalCommandName);
119
+ if (globalCommand) {
120
+ if (globalCommand.argument?.allowableValues) {
121
+ return globalCommand.argument.allowableValues
122
+ .filter((v) => String(v).startsWith(currentWord))
123
+ .map((v) => ({ value: String(v) }));
124
+ }
125
+ return [];
126
+ }
127
+ }
128
+
115
129
  // Check sub-command
116
130
  const subCommand = this.#commandRegistry!.getSubCommandByName(commandWord);
117
131
  if (subCommand) {
@@ -0,0 +1,59 @@
1
+ import type SubCommand from "../../../api/command/SubCommand.ts";
2
+ import type Option from "../../../api/argument/Option.ts";
3
+ import type Positional from "../../../api/argument/Positional.ts";
4
+ import type Context from "../../../api/Context.ts";
5
+ import {
6
+ type ArgumentValues,
7
+ ArgumentValueTypeName,
8
+ } from "../../../api/argument/ArgumentValueTypes.ts";
9
+ import { COMPLETION_SERVICE_ID, ShellType } from "../../../api/service/core/CompletionService.ts";
10
+ import type DefaultCompletionService from "../DefaultCompletionService.ts";
11
+ import { PRINTER_SERVICE_ID } from "../../../api/service/core/PrinterService.ts";
12
+ import type PrinterService from "../../../api/service/core/PrinterService.ts";
13
+
14
+ export class CompletionCompleteSubCommand implements SubCommand {
15
+ readonly name = "complete";
16
+ readonly description = "Generate completions for shell integration";
17
+ readonly enableConfiguration = false;
18
+ readonly disableGenericHelpDisplay = true;
19
+
20
+ readonly options: ReadonlyArray<Option> = [];
21
+
22
+ readonly positionals: ReadonlyArray<Positional> = [
23
+ {
24
+ name: "shell",
25
+ type: ArgumentValueTypeName.STRING,
26
+ allowableValues: Object.values(ShellType),
27
+ description: "Shell type",
28
+ },
29
+ {
30
+ name: "args",
31
+ type: ArgumentValueTypeName.STRING,
32
+ isVarargMultiple: true,
33
+ isVarargOptional: true,
34
+ description: "Shell-specific completion context arguments",
35
+ },
36
+ ];
37
+
38
+ async execute(context: Context, argumentValues: ArgumentValues): Promise<void> {
39
+ const completionService = context.getServiceById(
40
+ COMPLETION_SERVICE_ID,
41
+ ) as DefaultCompletionService;
42
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
43
+
44
+ const shellType = argumentValues.shell as ShellType;
45
+ const args = (argumentValues.args || []) as string[];
46
+
47
+ const completionContext = completionService.parseCompletionContext(shellType, args);
48
+ const completions = await completionService.generateCompletions(
49
+ shellType,
50
+ completionContext.line,
51
+ completionContext.cursorPosition,
52
+ );
53
+
54
+ const output = completionService.formatCompletions(shellType, completions);
55
+ if (output.length > 0) {
56
+ await printerService.print(output + "\n");
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,21 @@
1
+ import type GroupCommand from "../../../api/command/GroupCommand.ts";
2
+ import type SubCommand from "../../../api/command/SubCommand.ts";
3
+ import type Context from "../../../api/Context.ts";
4
+ import type { CompletionIntegrationSubCommand } from "./CompletionIntegrationSubCommand.ts";
5
+ import type { CompletionCompleteSubCommand } from "./CompletionCompleteSubCommand.ts";
6
+
7
+ export class CompletionGroupCommand implements GroupCommand {
8
+ readonly name = "completion";
9
+ readonly description = "Manage shell auto-completion";
10
+ readonly enableConfiguration = false;
11
+ readonly memberSubCommands: ReadonlyArray<SubCommand>;
12
+
13
+ constructor(
14
+ integrationCommand: CompletionIntegrationSubCommand,
15
+ completeCommand: CompletionCompleteSubCommand,
16
+ ) {
17
+ this.memberSubCommands = [integrationCommand, completeCommand];
18
+ }
19
+
20
+ async execute(_context: Context): Promise<void> {}
21
+ }
@@ -1,14 +1,16 @@
1
1
  import process from "node:process";
2
- import type GroupCommand from "../api/command/GroupCommand.ts";
3
- import type SubCommand from "../api/command/SubCommand.ts";
4
- import type Option from "../api/argument/Option.ts";
5
- import type Positional from "../api/argument/Positional.ts";
6
- import type Context from "../api/Context.ts";
7
- import { type ArgumentValues, ArgumentValueTypeName } from "../api/argument/ArgumentValueTypes.ts";
8
- import { COMPLETION_SERVICE_ID, ShellType } from "../api/service/core/CompletionService.ts";
9
- import type DefaultCompletionService from "../service/completion/DefaultCompletionService.ts";
10
- import { Icon, PRINTER_SERVICE_ID } from "../api/service/core/PrinterService.ts";
11
- import type PrinterService from "../api/service/core/PrinterService.ts";
2
+ import type SubCommand from "../../../api/command/SubCommand.ts";
3
+ import type Option from "../../../api/argument/Option.ts";
4
+ import type Positional from "../../../api/argument/Positional.ts";
5
+ import type Context from "../../../api/Context.ts";
6
+ import {
7
+ type ArgumentValues,
8
+ ArgumentValueTypeName,
9
+ } from "../../../api/argument/ArgumentValueTypes.ts";
10
+ import { COMPLETION_SERVICE_ID, ShellType } from "../../../api/service/core/CompletionService.ts";
11
+ import type DefaultCompletionService from "../DefaultCompletionService.ts";
12
+ import { Icon, PRINTER_SERVICE_ID } from "../../../api/service/core/PrinterService.ts";
13
+ import type PrinterService from "../../../api/service/core/PrinterService.ts";
12
14
 
13
15
  export class CompletionIntegrationSubCommand implements SubCommand {
14
16
  readonly name = "integration";
@@ -94,65 +96,3 @@ export class CompletionIntegrationSubCommand implements SubCommand {
94
96
  );
95
97
  }
96
98
  }
97
-
98
- export class CompletionCompleteSubCommand implements SubCommand {
99
- readonly name = "complete";
100
- readonly description = "Generate completions for shell integration";
101
- readonly enableConfiguration = false;
102
-
103
- readonly options: ReadonlyArray<Option> = [];
104
-
105
- readonly positionals: ReadonlyArray<Positional> = [
106
- {
107
- name: "shell",
108
- type: ArgumentValueTypeName.STRING,
109
- allowableValues: Object.values(ShellType),
110
- description: "Shell type",
111
- },
112
- {
113
- name: "args",
114
- type: ArgumentValueTypeName.STRING,
115
- isVarargMultiple: true,
116
- isVarargOptional: true,
117
- description: "Shell-specific completion context arguments",
118
- },
119
- ];
120
-
121
- async execute(context: Context, argumentValues: ArgumentValues): Promise<void> {
122
- const completionService = context.getServiceById(
123
- COMPLETION_SERVICE_ID,
124
- ) as DefaultCompletionService;
125
- const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
126
-
127
- const shellType = argumentValues.shell as ShellType;
128
- const args = (argumentValues.args || []) as string[];
129
-
130
- const completionContext = completionService.parseCompletionContext(shellType, args);
131
- const completions = await completionService.generateCompletions(
132
- shellType,
133
- completionContext.line,
134
- completionContext.cursorPosition,
135
- );
136
-
137
- const output = completionService.formatCompletions(shellType, completions);
138
- if (output.length > 0) {
139
- await printerService.print(output + "\n");
140
- }
141
- }
142
- }
143
-
144
- export class CompletionGroupCommand implements GroupCommand {
145
- readonly name = "completions";
146
- readonly description = "Manage shell auto-completion";
147
- readonly enableConfiguration = false;
148
- readonly memberSubCommands: ReadonlyArray<SubCommand>;
149
-
150
- constructor(
151
- integrationCommand: CompletionIntegrationSubCommand,
152
- completeCommand: CompletionCompleteSubCommand,
153
- ) {
154
- this.memberSubCommands = [integrationCommand, completeCommand];
155
- }
156
-
157
- async execute(_context: Context): Promise<void> {}
158
- }
@@ -16,7 +16,7 @@ export default class BashShellHandler implements ShellHandler {
16
16
  return [
17
17
  `_${cliName}_completions() {`,
18
18
  ` local IFS=$'\\n'`,
19
- ` COMPREPLY=( $("${executablePath}" completions:complete bash "\${COMP_LINE}" "\${COMP_POINT}") )`,
19
+ ` COMPREPLY=( $("${executablePath}" completion:complete bash "\${COMP_LINE}" "\${COMP_POINT}" 2>/dev/null) )`,
20
20
  `}`,
21
21
  `complete -F _${cliName}_completions ${cliName}`,
22
22
  ].join("\n");
@@ -13,7 +13,7 @@ export default class FishShellHandler implements ShellHandler {
13
13
  }
14
14
 
15
15
  getBootstrapScript(cliName: string, executablePath: string): string {
16
- return `complete -c ${cliName} -f -a '("${executablePath}" completions:complete fish (commandline -cp) (commandline -C))'`;
16
+ return `complete -c ${cliName} -f -a '("${executablePath}" completion:complete fish (commandline -cp) (commandline -C) 2>/dev/null)'`;
17
17
  }
18
18
 
19
19
  validateEnvironment(): Promise<boolean> {
@@ -19,7 +19,7 @@ export default class PowerShellShellHandler implements ShellHandler {
19
19
  return [
20
20
  `Register-ArgumentCompleter -Native -CommandName ${cliName} -ScriptBlock {`,
21
21
  ` param($wordToComplete, $commandAst, $cursorPosition)`,
22
- ` $completions = & "${executablePath}" completions:complete powershell "$commandAst" "$cursorPosition"`,
22
+ ` $completions = & "${executablePath}" completion:complete powershell "$commandAst" "$cursorPosition" 2>$null`,
23
23
  ` $completions -split '\\n' | ForEach-Object {`,
24
24
  ` [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)`,
25
25
  ` }`,
@@ -16,7 +16,7 @@ export default class ZshShellHandler implements ShellHandler {
16
16
  return [
17
17
  `_${cliName}_completions() {`,
18
18
  ` local -a completions`,
19
- ` completions=("\${(@f)$("${executablePath}" completions:complete zsh "\${words}" "\${CURSOR}")}")`,
19
+ ` completions=("\${(@f)$("${executablePath}" completion:complete zsh "\${words}" "\${CURSOR}" 2>/dev/null)}")`,
20
20
  ` _describe '${cliName}' completions`,
21
21
  `}`,
22
22
  `compdef _${cliName}_completions ${cliName}`,
@@ -1,10 +1,10 @@
1
- import type { ServiceProvider, ServiceInfo } from "../../api/service/ServiceProvider.ts";
1
+ import type { ServiceInfo, ServiceProvider } from "../../api/service/ServiceProvider.ts";
2
2
  import type Context from "../../api/Context.ts";
3
3
  import type CLIConfig from "../../api/CLIConfig.ts";
4
4
  import type { MarketplacePluginManager } from "@flowscripter/dynamic-plugin-framework";
5
5
  import { PLUGIN_SERVICE_ID } from "../../api/service/core/PluginService.ts";
6
6
  import DefaultPluginService from "./DefaultPluginService.ts";
7
- import { PluginGroupCommand } from "../../command/PluginCommand.ts";
7
+ import { PluginGroupCommand } from "./command/PluginGroupCommand.ts";
8
8
 
9
9
  export default class DefaultPluginServiceProvider implements ServiceProvider {
10
10
  readonly serviceId = PLUGIN_SERVICE_ID;
@@ -0,0 +1,64 @@
1
+ import type SubCommand from "../../../api/command/SubCommand.ts";
2
+ import type Context from "../../../api/Context.ts";
3
+ import type { ArgumentValues } from "../../../api/argument/ArgumentValueTypes.ts";
4
+ import { ArgumentValueTypeName } from "../../../api/argument/ArgumentValueTypes.ts";
5
+ import type PrinterService from "../../../api/service/core/PrinterService.ts";
6
+ import { Icon, PRINTER_SERVICE_ID } from "../../../api/service/core/PrinterService.ts";
7
+ import { PLUGIN_SERVICE_ID } from "../../../api/service/core/PluginService.ts";
8
+ import type PluginService from "../../../api/service/core/PluginService.ts";
9
+ import type { VersionedPluginDescriptor } from "@flowscripter/dynamic-plugin-framework";
10
+ import { getPluginId } from "./getPluginId.ts";
11
+
12
+ export class PluginAddSubCommand implements SubCommand {
13
+ readonly name = "add";
14
+ readonly description = "Install a remote plugin";
15
+ readonly enableConfiguration = false;
16
+ readonly options = [];
17
+ readonly positionals = [
18
+ {
19
+ name: "pluginId",
20
+ description: "Plugin ID to install (e.g. @scope/name)",
21
+ type: ArgumentValueTypeName.STRING,
22
+ },
23
+ ];
24
+
25
+ async execute(context: Context, argumentValues: ArgumentValues): Promise<void> {
26
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
27
+ const pluginService = context.getServiceById(PLUGIN_SERVICE_ID) as PluginService;
28
+
29
+ const pluginId = argumentValues["pluginId"] as string;
30
+ await printerService.info(`Searching for plugin: ${pluginId}\n`, Icon.INFORMATION);
31
+
32
+ let descriptor: VersionedPluginDescriptor | undefined;
33
+ for await (const d of pluginService.search({ text: pluginId })) {
34
+ if (getPluginId(d) === pluginId || d.pluginId === pluginId) {
35
+ descriptor = d;
36
+ break;
37
+ }
38
+ }
39
+
40
+ if (!descriptor) {
41
+ // Search did not find an exact match - attempt direct install by plugin ID.
42
+ // This handles cases where the package exists on the registry but is not
43
+ // returned by search (e.g. recently published or low search ranking).
44
+ await printerService.info(
45
+ `Plugin not found via search, attempting direct install of ${pluginId}...\n`,
46
+ Icon.INFORMATION,
47
+ );
48
+ const parts = pluginId.startsWith("@") ? pluginId.slice(1).split("/") : [undefined, pluginId];
49
+ const scope = pluginId.startsWith("@") ? `@${parts[0]}` : undefined;
50
+ const name = pluginId.startsWith("@") ? parts[1]! : pluginId;
51
+ descriptor = {
52
+ pluginId,
53
+ scope,
54
+ name,
55
+ version: "latest",
56
+ extensionPoints: [],
57
+ };
58
+ }
59
+
60
+ await printerService.info(`Installing ${descriptor.pluginId}...\n`, Icon.INFORMATION);
61
+ await pluginService.install(descriptor);
62
+ await printerService.print(`Plugin ${descriptor.pluginId} installed.\n`, Icon.SUCCESS);
63
+ }
64
+ }
@@ -0,0 +1,27 @@
1
+ import type GroupCommand from "../../../api/command/GroupCommand.ts";
2
+ import type SubCommand from "../../../api/command/SubCommand.ts";
3
+ import type Context from "../../../api/Context.ts";
4
+ import { PluginListSubCommand } from "./PluginListSubCommand.ts";
5
+ import { PluginSearchSubCommand } from "./PluginSearchSubCommand.ts";
6
+ import { PluginAddSubCommand } from "./PluginAddSubCommand.ts";
7
+ import { PluginRemoveSubCommand } from "./PluginRemoveSubCommand.ts";
8
+ import { PluginUpgradeSubCommand } from "./PluginUpgradeSubCommand.ts";
9
+
10
+ export class PluginGroupCommand implements GroupCommand {
11
+ readonly name = "plugin";
12
+ readonly description = "Manage CLI plugins";
13
+ readonly enableConfiguration = false;
14
+ readonly memberSubCommands: ReadonlyArray<SubCommand>;
15
+
16
+ constructor() {
17
+ this.memberSubCommands = [
18
+ new PluginListSubCommand(),
19
+ new PluginSearchSubCommand(),
20
+ new PluginAddSubCommand(),
21
+ new PluginRemoveSubCommand(),
22
+ new PluginUpgradeSubCommand(),
23
+ ];
24
+ }
25
+
26
+ async execute(_context: Context): Promise<void> {}
27
+ }
@@ -0,0 +1,33 @@
1
+ import type SubCommand from "../../../api/command/SubCommand.ts";
2
+ import type Context from "../../../api/Context.ts";
3
+ import type { ArgumentValues } from "../../../api/argument/ArgumentValueTypes.ts";
4
+ import type PrinterService from "../../../api/service/core/PrinterService.ts";
5
+ import { PRINTER_SERVICE_ID } from "../../../api/service/core/PrinterService.ts";
6
+ import { PLUGIN_SERVICE_ID } from "../../../api/service/core/PluginService.ts";
7
+ import type PluginService from "../../../api/service/core/PluginService.ts";
8
+ import { getPluginId } from "./getPluginId.ts";
9
+
10
+ export class PluginListSubCommand implements SubCommand {
11
+ readonly name = "list";
12
+ readonly description = "List locally installed plugins";
13
+ readonly enableConfiguration = false;
14
+ readonly options = [];
15
+ readonly positionals = [];
16
+
17
+ async execute(context: Context, _argumentValues: ArgumentValues): Promise<void> {
18
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
19
+ const pluginService = context.getServiceById(PLUGIN_SERVICE_ID) as PluginService;
20
+
21
+ let found = false;
22
+ for await (const descriptor of pluginService.listInstalled()) {
23
+ if (!found) {
24
+ found = true;
25
+ await printerService.print("Installed plugins:\n");
26
+ }
27
+ await printerService.print(` ${getPluginId(descriptor)} ${descriptor.version}\n`);
28
+ }
29
+ if (!found) {
30
+ await printerService.print("No plugins installed.\n");
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,32 @@
1
+ import type SubCommand from "../../../api/command/SubCommand.ts";
2
+ import type Context from "../../../api/Context.ts";
3
+ import type { ArgumentValues } from "../../../api/argument/ArgumentValueTypes.ts";
4
+ import { ArgumentValueTypeName } from "../../../api/argument/ArgumentValueTypes.ts";
5
+ import type PrinterService from "../../../api/service/core/PrinterService.ts";
6
+ import { Icon, PRINTER_SERVICE_ID } from "../../../api/service/core/PrinterService.ts";
7
+ import { PLUGIN_SERVICE_ID } from "../../../api/service/core/PluginService.ts";
8
+ import type PluginService from "../../../api/service/core/PluginService.ts";
9
+
10
+ export class PluginRemoveSubCommand implements SubCommand {
11
+ readonly name = "remove";
12
+ readonly description = "Remove a locally installed plugin";
13
+ readonly enableConfiguration = false;
14
+ readonly options = [];
15
+ readonly positionals = [
16
+ {
17
+ name: "pluginId",
18
+ description: "Plugin ID to remove (e.g. @scope/name)",
19
+ type: ArgumentValueTypeName.STRING,
20
+ },
21
+ ];
22
+
23
+ async execute(context: Context, argumentValues: ArgumentValues): Promise<void> {
24
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
25
+ const pluginService = context.getServiceById(PLUGIN_SERVICE_ID) as PluginService;
26
+
27
+ const pluginId = argumentValues["pluginId"] as string;
28
+ await printerService.info(`Removing plugin: ${pluginId}...\n`, Icon.INFORMATION);
29
+ await pluginService.uninstall(pluginId);
30
+ await printerService.print(`Plugin ${pluginId} removed.\n`, Icon.SUCCESS);
31
+ }
32
+ }