track-cli 3.0.0-rc

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 (224) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +3 -0
  3. package/esm/_dnt.polyfills.d.ts +6 -0
  4. package/esm/_dnt.polyfills.js +1 -0
  5. package/esm/_dnt.shims.d.ts +19 -0
  6. package/esm/_dnt.shims.js +78 -0
  7. package/esm/deps/deno.land/std@0.170.0/fmt/colors.d.ts +270 -0
  8. package/esm/deps/deno.land/std@0.170.0/fmt/colors.js +473 -0
  9. package/esm/deps/deno.land/std@0.195.0/_util/os.d.ts +4 -0
  10. package/esm/deps/deno.land/std@0.195.0/_util/os.js +18 -0
  11. package/esm/deps/deno.land/std@0.195.0/assert/assert.d.ts +2 -0
  12. package/esm/deps/deno.land/std@0.195.0/assert/assert.js +8 -0
  13. package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.d.ts +4 -0
  14. package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.js +12 -0
  15. package/esm/deps/deno.land/std@0.195.0/datetime/_common.d.ts +50 -0
  16. package/esm/deps/deno.land/std@0.195.0/datetime/_common.js +545 -0
  17. package/esm/deps/deno.land/std@0.195.0/datetime/constants.d.ts +55 -0
  18. package/esm/deps/deno.land/std@0.195.0/datetime/constants.js +57 -0
  19. package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.d.ts +26 -0
  20. package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.js +45 -0
  21. package/esm/deps/deno.land/std@0.195.0/datetime/difference.d.ts +38 -0
  22. package/esm/deps/deno.land/std@0.195.0/datetime/difference.js +93 -0
  23. package/esm/deps/deno.land/std@0.195.0/datetime/format.d.ts +22 -0
  24. package/esm/deps/deno.land/std@0.195.0/datetime/format.js +28 -0
  25. package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.d.ts +49 -0
  26. package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.js +60 -0
  27. package/esm/deps/deno.land/std@0.195.0/datetime/mod.d.ts +43 -0
  28. package/esm/deps/deno.land/std@0.195.0/datetime/mod.js +45 -0
  29. package/esm/deps/deno.land/std@0.195.0/datetime/parse.d.ts +21 -0
  30. package/esm/deps/deno.land/std@0.195.0/datetime/parse.js +29 -0
  31. package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.d.ts +17 -0
  32. package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.js +44 -0
  33. package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.d.ts +13 -0
  34. package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.js +38 -0
  35. package/esm/deps/deno.land/std@0.195.0/fmt/colors.d.ts +270 -0
  36. package/esm/deps/deno.land/std@0.195.0/fmt/colors.js +474 -0
  37. package/esm/deps/deno.land/std@0.195.0/fmt/duration.d.ts +15 -0
  38. package/esm/deps/deno.land/std@0.195.0/fmt/duration.js +96 -0
  39. package/esm/deps/deno.land/std@0.195.0/fs/_util.d.ts +35 -0
  40. package/esm/deps/deno.land/std@0.195.0/fs/_util.js +80 -0
  41. package/esm/deps/deno.land/std@0.195.0/fs/copy.d.ts +51 -0
  42. package/esm/deps/deno.land/std@0.195.0/fs/copy.js +244 -0
  43. package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.d.ts +31 -0
  44. package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.js +74 -0
  45. package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.d.ts +27 -0
  46. package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.js +55 -0
  47. package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.d.ts +33 -0
  48. package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.js +75 -0
  49. package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.d.ts +31 -0
  50. package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.js +43 -0
  51. package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.d.ts +17 -0
  52. package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.js +68 -0
  53. package/esm/deps/deno.land/std@0.195.0/fs/eol.d.ts +40 -0
  54. package/esm/deps/deno.land/std@0.195.0/fs/eol.js +53 -0
  55. package/esm/deps/deno.land/std@0.195.0/fs/exists.d.ts +102 -0
  56. package/esm/deps/deno.land/std@0.195.0/fs/exists.js +163 -0
  57. package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.d.ts +37 -0
  58. package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.js +216 -0
  59. package/esm/deps/deno.land/std@0.195.0/fs/mod.d.ts +16 -0
  60. package/esm/deps/deno.land/std@0.195.0/fs/mod.js +17 -0
  61. package/esm/deps/deno.land/std@0.195.0/fs/move.d.ts +29 -0
  62. package/esm/deps/deno.land/std@0.195.0/fs/move.js +88 -0
  63. package/esm/deps/deno.land/std@0.195.0/fs/walk.d.ts +40 -0
  64. package/esm/deps/deno.land/std@0.195.0/fs/walk.js +158 -0
  65. package/esm/deps/deno.land/std@0.195.0/path/_constants.d.ts +39 -0
  66. package/esm/deps/deno.land/std@0.195.0/path/_constants.js +46 -0
  67. package/esm/deps/deno.land/std@0.195.0/path/_interface.d.ts +26 -0
  68. package/esm/deps/deno.land/std@0.195.0/path/_interface.js +3 -0
  69. package/esm/deps/deno.land/std@0.195.0/path/_util.d.ts +11 -0
  70. package/esm/deps/deno.land/std@0.195.0/path/_util.js +161 -0
  71. package/esm/deps/deno.land/std@0.195.0/path/common.d.ts +13 -0
  72. package/esm/deps/deno.land/std@0.195.0/path/common.js +36 -0
  73. package/esm/deps/deno.land/std@0.195.0/path/glob.d.ts +83 -0
  74. package/esm/deps/deno.land/std@0.195.0/path/glob.js +361 -0
  75. package/esm/deps/deno.land/std@0.195.0/path/mod.d.ts +9 -0
  76. package/esm/deps/deno.land/std@0.195.0/path/mod.js +33 -0
  77. package/esm/deps/deno.land/std@0.195.0/path/posix.d.ts +86 -0
  78. package/esm/deps/deno.land/std@0.195.0/path/posix.js +442 -0
  79. package/esm/deps/deno.land/std@0.195.0/path/separator.d.ts +2 -0
  80. package/esm/deps/deno.land/std@0.195.0/path/separator.js +5 -0
  81. package/esm/deps/deno.land/std@0.195.0/path/win32.d.ts +91 -0
  82. package/esm/deps/deno.land/std@0.195.0/path/win32.js +909 -0
  83. package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.d.ts +1 -0
  84. package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.js +26 -0
  85. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.d.ts +76 -0
  86. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.js +154 -0
  87. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.d.ts +32 -0
  88. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.js +105 -0
  89. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.d.ts +831 -0
  90. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.js +1701 -0
  91. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.d.ts +17 -0
  92. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.js +201 -0
  93. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.d.ts +14 -0
  94. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.js +141 -0
  95. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.d.ts +21 -0
  96. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.js +285 -0
  97. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.d.ts +6 -0
  98. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.js +38 -0
  99. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.d.ts +8 -0
  100. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.js +32 -0
  101. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.d.ts +6 -0
  102. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.js +38 -0
  103. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.d.ts +6 -0
  104. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.js +46 -0
  105. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.d.ts +6 -0
  106. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.js +38 -0
  107. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.d.ts +45 -0
  108. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.js +2 -0
  109. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.d.ts +1 -0
  110. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.js +1 -0
  111. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.d.ts +27 -0
  112. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.js +323 -0
  113. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.d.ts +6 -0
  114. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.js +34 -0
  115. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.d.ts +18 -0
  116. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.js +17 -0
  117. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.d.ts +41 -0
  118. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.js +24 -0
  119. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.d.ts +9 -0
  120. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.js +20 -0
  121. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.d.ts +9 -0
  122. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.js +13 -0
  123. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.d.ts +9 -0
  124. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.js +27 -0
  125. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.d.ts +7 -0
  126. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.js +9 -0
  127. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.d.ts +10 -0
  128. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.js +29 -0
  129. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.d.ts +5 -0
  130. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.js +12 -0
  131. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.d.ts +7 -0
  132. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.js +9 -0
  133. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.d.ts +7 -0
  134. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.js +9 -0
  135. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.d.ts +7 -0
  136. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.js +9 -0
  137. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.d.ts +118 -0
  138. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.js +2 -0
  139. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.d.ts +5 -0
  140. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.js +5 -0
  141. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.d.ts +14 -0
  142. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.js +46 -0
  143. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.d.ts +26 -0
  144. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.js +118 -0
  145. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.d.ts +14 -0
  146. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.js +55 -0
  147. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.d.ts +27 -0
  148. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.js +102 -0
  149. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.d.ts +17 -0
  150. package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.js +75 -0
  151. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.d.ts +60 -0
  152. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.js +117 -0
  153. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.d.ts +18 -0
  154. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.js +106 -0
  155. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.d.ts +10 -0
  156. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.js +157 -0
  157. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.d.ts +24 -0
  158. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.js +9 -0
  159. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.d.ts +33 -0
  160. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.js +402 -0
  161. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.d.ts +3 -0
  162. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.js +11 -0
  163. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.d.ts +3 -0
  164. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.js +9 -0
  165. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.d.ts +3 -0
  166. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.js +9 -0
  167. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.d.ts +3 -0
  168. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.js +4 -0
  169. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.d.ts +59 -0
  170. package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.js +1 -0
  171. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.d.ts +20 -0
  172. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.js +18 -0
  173. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.d.ts +78 -0
  174. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.js +128 -0
  175. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.d.ts +1 -0
  176. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.js +1 -0
  177. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.d.ts +99 -0
  178. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.js +529 -0
  179. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.d.ts +49 -0
  180. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.js +74 -0
  181. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.d.ts +135 -0
  182. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.js +237 -0
  183. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.d.ts +13 -0
  184. package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.js +60 -0
  185. package/esm/package.json +3 -0
  186. package/esm/src/action/add.d.ts +1 -0
  187. package/esm/src/action/add.js +57 -0
  188. package/esm/src/action/clone.d.ts +6 -0
  189. package/esm/src/action/clone.js +108 -0
  190. package/esm/src/action/lang.d.ts +1 -0
  191. package/esm/src/action/lang.js +40 -0
  192. package/esm/src/action/pull.d.ts +1 -0
  193. package/esm/src/action/pull.js +22 -0
  194. package/esm/src/action/remove.d.ts +4 -0
  195. package/esm/src/action/remove.js +67 -0
  196. package/esm/src/action/reset.d.ts +1 -0
  197. package/esm/src/action/reset.js +21 -0
  198. package/esm/src/action/run.d.ts +4 -0
  199. package/esm/src/action/run.js +163 -0
  200. package/esm/src/action/status.d.ts +1 -0
  201. package/esm/src/action/status.js +5 -0
  202. package/esm/src/main.d.ts +2 -0
  203. package/esm/src/main.js +96 -0
  204. package/esm/src/meta.d.ts +3 -0
  205. package/esm/src/meta.js +51 -0
  206. package/esm/src/orca/client.d.ts +20 -0
  207. package/esm/src/orca/client.js +152 -0
  208. package/esm/src/orca/types.d.ts +54 -0
  209. package/esm/src/orca/types.js +12 -0
  210. package/esm/src/shared/config.d.ts +24 -0
  211. package/esm/src/shared/config.js +24 -0
  212. package/esm/src/shared/errors.d.ts +82 -0
  213. package/esm/src/shared/errors.js +228 -0
  214. package/esm/src/shared/file.d.ts +30 -0
  215. package/esm/src/shared/file.js +110 -0
  216. package/esm/src/shared/mod.d.ts +40 -0
  217. package/esm/src/shared/mod.js +383 -0
  218. package/esm/src/shared/types.d.ts +12 -0
  219. package/esm/src/shared/types.js +1 -0
  220. package/esm/src/track/client.d.ts +60 -0
  221. package/esm/src/track/client.js +268 -0
  222. package/esm/src/track/types.d.ts +210 -0
  223. package/esm/src/track/types.js +40 -0
  224. package/package.json +35 -0
@@ -0,0 +1,38 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _BashCompletionsCommand_cmd;
13
+ import { Command } from "../command.js";
14
+ import { dim, italic } from "../deps.js";
15
+ import { BashCompletionsGenerator } from "./_bash_completions_generator.js";
16
+ /** Generates bash completions script. */
17
+ export class BashCompletionsCommand extends Command {
18
+ constructor(cmd) {
19
+ super();
20
+ _BashCompletionsCommand_cmd.set(this, void 0);
21
+ __classPrivateFieldSet(this, _BashCompletionsCommand_cmd, cmd, "f");
22
+ return this
23
+ .description(() => {
24
+ const baseCmd = __classPrivateFieldGet(this, _BashCompletionsCommand_cmd, "f") || this.getMainCommand();
25
+ return `Generate shell completions for bash.
26
+
27
+ To enable bash completions for this program add following line to your ${dim(italic("~/.bashrc"))}:
28
+
29
+ ${dim(italic(`source <(${baseCmd.getPath()} completions bash)`))}`;
30
+ })
31
+ .noGlobals()
32
+ .action(() => {
33
+ const baseCmd = __classPrivateFieldGet(this, _BashCompletionsCommand_cmd, "f") || this.getMainCommand();
34
+ console.log(BashCompletionsGenerator.generate(baseCmd));
35
+ });
36
+ }
37
+ }
38
+ _BashCompletionsCommand_cmd = new WeakMap();
@@ -0,0 +1,8 @@
1
+ import { Command } from "../command.js";
2
+ /** Execute auto completion method of command and action. */
3
+ export declare class CompleteCommand extends Command<void, void, void, [
4
+ action: string,
5
+ ...commandNames: Array<string>
6
+ ]> {
7
+ constructor(cmd?: Command);
8
+ }
@@ -0,0 +1,32 @@
1
+ import * as dntShim from "../../../../../../_dnt.shims.js";
2
+ import { Command } from "../command.js";
3
+ import { UnknownCompletionCommandError } from "../_errors.js";
4
+ /** Execute auto completion method of command and action. */
5
+ export class CompleteCommand extends Command {
6
+ constructor(cmd) {
7
+ super();
8
+ return this
9
+ .description("Get completions for given action from given command.")
10
+ .noGlobals()
11
+ .arguments("<action:string> [command...:string]")
12
+ .action(async (_, action, ...commandNames) => {
13
+ let parent;
14
+ const completeCommand = commandNames
15
+ ?.reduce((cmd, name) => {
16
+ parent = cmd;
17
+ const childCmd = cmd.getCommand(name, false);
18
+ if (!childCmd) {
19
+ throw new UnknownCompletionCommandError(name, cmd.getCommands());
20
+ }
21
+ return childCmd;
22
+ }, cmd || this.getMainCommand()) ?? (cmd || this.getMainCommand());
23
+ const completion = completeCommand
24
+ .getCompletion(action);
25
+ const result = await completion?.complete(completeCommand, parent) ?? [];
26
+ if (result?.length) {
27
+ dntShim.Deno.stdout.writeSync(new TextEncoder().encode(result.join("\n")));
28
+ }
29
+ })
30
+ .reset();
31
+ }
32
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from "../command.js";
2
+ /** Generates fish completions script. */
3
+ export declare class FishCompletionsCommand extends Command {
4
+ #private;
5
+ constructor(cmd?: Command);
6
+ }
@@ -0,0 +1,38 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _FishCompletionsCommand_cmd;
13
+ import { Command } from "../command.js";
14
+ import { dim, italic } from "../deps.js";
15
+ import { FishCompletionsGenerator } from "./_fish_completions_generator.js";
16
+ /** Generates fish completions script. */
17
+ export class FishCompletionsCommand extends Command {
18
+ constructor(cmd) {
19
+ super();
20
+ _FishCompletionsCommand_cmd.set(this, void 0);
21
+ __classPrivateFieldSet(this, _FishCompletionsCommand_cmd, cmd, "f");
22
+ return this
23
+ .description(() => {
24
+ const baseCmd = __classPrivateFieldGet(this, _FishCompletionsCommand_cmd, "f") || this.getMainCommand();
25
+ return `Generate shell completions for fish.
26
+
27
+ To enable fish completions for this program add following line to your ${dim(italic("~/.config/fish/config.fish"))}:
28
+
29
+ ${dim(italic(`source (${baseCmd.getPath()} completions fish | psub)`))}`;
30
+ })
31
+ .noGlobals()
32
+ .action(() => {
33
+ const baseCmd = __classPrivateFieldGet(this, _FishCompletionsCommand_cmd, "f") || this.getMainCommand();
34
+ console.log(FishCompletionsGenerator.generate(baseCmd));
35
+ });
36
+ }
37
+ }
38
+ _FishCompletionsCommand_cmd = new WeakMap();
@@ -0,0 +1,6 @@
1
+ import { Command } from "../command.js";
2
+ /** Generates shell completion scripts for various shells. */
3
+ export declare class CompletionsCommand extends Command {
4
+ #private;
5
+ constructor(cmd?: Command);
6
+ }
@@ -0,0 +1,46 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _CompletionsCommand_cmd;
13
+ import { Command } from "../command.js";
14
+ import { dim, italic } from "../deps.js";
15
+ import { BashCompletionsCommand } from "./bash.js";
16
+ import { CompleteCommand } from "./complete.js";
17
+ import { FishCompletionsCommand } from "./fish.js";
18
+ import { ZshCompletionsCommand } from "./zsh.js";
19
+ /** Generates shell completion scripts for various shells. */
20
+ export class CompletionsCommand extends Command {
21
+ constructor(cmd) {
22
+ super();
23
+ _CompletionsCommand_cmd.set(this, void 0);
24
+ __classPrivateFieldSet(this, _CompletionsCommand_cmd, cmd, "f");
25
+ return this
26
+ .description(() => {
27
+ const baseCmd = __classPrivateFieldGet(this, _CompletionsCommand_cmd, "f") || this.getMainCommand();
28
+ return `Generate shell completions.
29
+
30
+ To enable shell completions for this program add the following line to your ${dim(italic("~/.bashrc"))} or similar:
31
+
32
+ ${dim(italic(`source <(${baseCmd.getPath()} completions [shell])`))}
33
+
34
+ For more information run ${dim(italic(`${baseCmd.getPath()} completions [shell] --help`))}
35
+ `;
36
+ })
37
+ .noGlobals()
38
+ .action(() => this.showHelp())
39
+ .command("bash", new BashCompletionsCommand(__classPrivateFieldGet(this, _CompletionsCommand_cmd, "f")))
40
+ .command("fish", new FishCompletionsCommand(__classPrivateFieldGet(this, _CompletionsCommand_cmd, "f")))
41
+ .command("zsh", new ZshCompletionsCommand(__classPrivateFieldGet(this, _CompletionsCommand_cmd, "f")))
42
+ .command("complete", new CompleteCommand(__classPrivateFieldGet(this, _CompletionsCommand_cmd, "f")).hidden())
43
+ .reset();
44
+ }
45
+ }
46
+ _CompletionsCommand_cmd = new WeakMap();
@@ -0,0 +1,6 @@
1
+ import { Command } from "../command.js";
2
+ /** Generates zsh completions script. */
3
+ export declare class ZshCompletionsCommand extends Command {
4
+ #private;
5
+ constructor(cmd?: Command);
6
+ }
@@ -0,0 +1,38 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ZshCompletionsCommand_cmd;
13
+ import { Command } from "../command.js";
14
+ import { dim, italic } from "../deps.js";
15
+ import { ZshCompletionsGenerator } from "./_zsh_completions_generator.js";
16
+ /** Generates zsh completions script. */
17
+ export class ZshCompletionsCommand extends Command {
18
+ constructor(cmd) {
19
+ super();
20
+ _ZshCompletionsCommand_cmd.set(this, void 0);
21
+ __classPrivateFieldSet(this, _ZshCompletionsCommand_cmd, cmd, "f");
22
+ return this
23
+ .description(() => {
24
+ const baseCmd = __classPrivateFieldGet(this, _ZshCompletionsCommand_cmd, "f") || this.getMainCommand();
25
+ return `Generate shell completions for zsh.
26
+
27
+ To enable zsh completions for this program add following line to your ${dim(italic("~/.zshrc"))}:
28
+
29
+ ${dim(italic(`source <(${baseCmd.getPath()} completions zsh)`))}`;
30
+ })
31
+ .noGlobals()
32
+ .action(() => {
33
+ const baseCmd = __classPrivateFieldGet(this, _ZshCompletionsCommand_cmd, "f") || this.getMainCommand();
34
+ console.log(ZshCompletionsGenerator.generate(baseCmd));
35
+ });
36
+ }
37
+ }
38
+ _ZshCompletionsCommand_cmd = new WeakMap();
@@ -0,0 +1,45 @@
1
+ import type { Command } from "./command.js";
2
+ import type { Type } from "./type.js";
3
+ import type { ActionHandler, Argument, CommandResult, CompleteHandler, CompleteOptions, Completion, Description, EnvVar, EnvVarOptions, EnvVarValueHandler, Example, GlobalEnvVarOptions, GlobalOptionOptions, HelpHandler, Option, OptionOptions, OptionValueHandler, TypeDef, TypeOptions, VersionHandler } from "./types.js";
4
+ /** @deprecated Use `Argument` instead. */
5
+ export type IArgument = Argument;
6
+ /** @deprecated Use `GlobalOptionOptions` instead. */
7
+ export type ICommandGlobalOption<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = GlobalOptionOptions<O, A, G, PG, CT, GT, PT, P>;
8
+ /** @deprecated Use `OptionOptions` instead. */
9
+ export type ICommandOption<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = OptionOptions<O, A, G, PG, CT, GT, PT, P>;
10
+ /** @deprecated Use `CompleteOptions` instead. */
11
+ export type ICompleteOptions = CompleteOptions;
12
+ /** @deprecated Use `Completion` instead. */
13
+ export type ICompletion<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = Completion<O, A, G, PG, CT, GT, PT, P>;
14
+ /** @deprecated Use `EnvVar` instead. */
15
+ export type IEnvVar = EnvVar;
16
+ /** @deprecated Use `EnvVarOptions` instead. */
17
+ export type IEnvVarOptions = EnvVarOptions;
18
+ /** @deprecated Use `Example` instead. */
19
+ export type IExample = Example;
20
+ /** @deprecated Use `GlobalEnvVarOptions` instead. */
21
+ export type IGlobalEnvVarOptions = GlobalEnvVarOptions;
22
+ /** @deprecated Use `Option` instead. */
23
+ export type IOption<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = Option<O, A, G, PG, CT, GT, PT, P>;
24
+ /** @deprecated Use `CommandResult` instead. */
25
+ export type IParseResult<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = CommandResult<O, A, G, PG, CT, GT, PT, P>;
26
+ /** @deprecated Use `TypeDef` instead. */
27
+ export type IType = TypeDef;
28
+ /** @deprecated Use `TypeOptions` instead. */
29
+ export type ITypeOptions = TypeOptions;
30
+ /** @deprecated Use `ActionHandler` instead. */
31
+ export type IAction<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = ActionHandler<O, A, G, PG, CT, GT, PT, P>;
32
+ /** @deprecated Use `CompleteHandler` instead. */
33
+ export type ICompleteHandler<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = CompleteHandler<O, A, G, PG, CT, GT, PT, P>;
34
+ /** @deprecated Use `Description` instead. */
35
+ export type IDescription<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined> = Description<O, A, G, PG, CT, GT, PT, P>;
36
+ /** @deprecated Use `EnvVarValueHandler` instead. */
37
+ export type IEnvVarValueHandler<TValue = any, TReturn = TValue> = EnvVarValueHandler<TValue, TReturn>;
38
+ /** @deprecated Use `OptionValueHandler` instead. */
39
+ export type IFlagValueHandler<TValue = any, TReturn = TValue> = OptionValueHandler<TValue, TReturn>;
40
+ /** @deprecated Use `HelpHandler` instead. */
41
+ export type IHelpHandler<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined, C extends Command<PG, PT, O, A, G, CT, GT, P> = Command<PG, PT, O, A, G, CT, GT, P>> = HelpHandler<O, A, G, PG, CT, GT, PT, P>;
42
+ /** @deprecated Use `VersionHandler` instead. */
43
+ export type IVersionHandler<O extends Record<string, any> | void = any, A extends Array<unknown> = O extends number ? any : [], G extends Record<string, any> | void = O extends number ? any : void, PG extends Record<string, any> | void = O extends number ? any : void, CT extends Record<string, any> | void = O extends number ? any : void, GT extends Record<string, any> | void = O extends number ? any : void, PT extends Record<string, any> | void = O extends number ? any : void, P extends Command<any> | undefined = O extends number ? any : undefined, C extends Command<PG, PT, O, A, G, CT, GT, P> = Command<PG, PT, O, A, G, CT, GT, P>> = VersionHandler<O, A, G, PG, CT, GT, PT, P>;
44
+ /** @deprecated Use `Type.infer` instead. */
45
+ export type TypeValue<TType, TDefault = TType> = Type.infer<TType, TDefault>;
@@ -0,0 +1,2 @@
1
+ // deno-lint-ignore-file no-explicit-any
2
+ export {};
@@ -0,0 +1 @@
1
+ export { bold, brightBlue, brightMagenta, cyan, dim, getColorEnabled, green, italic, red, setColorEnabled, yellow, } from "../../../std@0.170.0/fmt/colors.js";
@@ -0,0 +1 @@
1
+ export { bold, brightBlue, brightMagenta, cyan, dim, getColorEnabled, green, italic, red, setColorEnabled, yellow, } from "../../../std@0.170.0/fmt/colors.js";
@@ -0,0 +1,27 @@
1
+ import type { Command } from "../command.js";
2
+ export interface HelpOptions {
3
+ types?: boolean;
4
+ hints?: boolean;
5
+ colors?: boolean;
6
+ long?: boolean;
7
+ }
8
+ /** Help text generator. */
9
+ export declare class HelpGenerator {
10
+ private cmd;
11
+ private indent;
12
+ private options;
13
+ /** Generate help text for given command. */
14
+ static generate(cmd: Command, options?: HelpOptions): string;
15
+ private constructor();
16
+ private generate;
17
+ private generateHeader;
18
+ private generateMeta;
19
+ private generateDescription;
20
+ private generateOptions;
21
+ private generateOptionGroup;
22
+ private generateCommands;
23
+ private generateEnvironmentVariables;
24
+ private generateExamples;
25
+ private generateHints;
26
+ private label;
27
+ }
@@ -0,0 +1,323 @@
1
+ import * as dntShim from "../../../../../../_dnt.shims.js";
2
+ import { getFlag } from "../../flags/_utils.js";
3
+ import { Table } from "../../table/table.js";
4
+ import { dedent, getDescription, parseArgumentsDefinition } from "../_utils.js";
5
+ import { bold, brightBlue, brightMagenta, dim, getColorEnabled, green, italic, red, setColorEnabled, yellow, } from "../deps.js";
6
+ import { Type } from "../type.js";
7
+ /** Help text generator. */
8
+ export class HelpGenerator {
9
+ /** Generate help text for given command. */
10
+ static generate(cmd, options) {
11
+ return new HelpGenerator(cmd, options).generate();
12
+ }
13
+ constructor(cmd, options = {}) {
14
+ Object.defineProperty(this, "cmd", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: cmd
19
+ });
20
+ Object.defineProperty(this, "indent", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: 2
25
+ });
26
+ Object.defineProperty(this, "options", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ this.options = {
33
+ types: false,
34
+ hints: true,
35
+ colors: true,
36
+ long: false,
37
+ ...options,
38
+ };
39
+ }
40
+ generate() {
41
+ const areColorsEnabled = getColorEnabled();
42
+ setColorEnabled(this.options.colors);
43
+ const result = this.generateHeader() +
44
+ this.generateMeta() +
45
+ this.generateDescription() +
46
+ this.generateOptions() +
47
+ this.generateCommands() +
48
+ this.generateEnvironmentVariables() +
49
+ this.generateExamples();
50
+ setColorEnabled(areColorsEnabled);
51
+ return result;
52
+ }
53
+ generateHeader() {
54
+ const usage = this.cmd.getUsage();
55
+ const rows = [
56
+ [
57
+ bold("Usage:"),
58
+ brightMagenta(this.cmd.getPath() +
59
+ (usage ? " " + highlightArguments(usage, this.options.types) : "")),
60
+ ],
61
+ ];
62
+ const version = this.cmd.getVersion();
63
+ if (version) {
64
+ rows.push([bold("Version:"), yellow(`${this.cmd.getVersion()}`)]);
65
+ }
66
+ return "\n" +
67
+ Table.from(rows)
68
+ .indent(this.indent)
69
+ .padding(1)
70
+ .toString() +
71
+ "\n";
72
+ }
73
+ generateMeta() {
74
+ const meta = Object.entries(this.cmd.getMeta());
75
+ if (!meta.length) {
76
+ return "";
77
+ }
78
+ const rows = [];
79
+ for (const [name, value] of meta) {
80
+ rows.push([bold(`${name}: `) + value]);
81
+ }
82
+ return "\n" +
83
+ Table.from(rows)
84
+ .indent(this.indent)
85
+ .padding(1)
86
+ .toString() +
87
+ "\n";
88
+ }
89
+ generateDescription() {
90
+ if (!this.cmd.getDescription()) {
91
+ return "";
92
+ }
93
+ return this.label("Description") +
94
+ Table.from([
95
+ [dedent(this.cmd.getDescription())],
96
+ ])
97
+ .indent(this.indent * 2)
98
+ .maxColWidth(140)
99
+ .padding(1)
100
+ .toString() +
101
+ "\n";
102
+ }
103
+ generateOptions() {
104
+ const options = this.cmd.getOptions(false);
105
+ if (!options.length) {
106
+ return "";
107
+ }
108
+ let groups = [];
109
+ const hasGroups = options.some((option) => option.groupName);
110
+ if (hasGroups) {
111
+ for (const option of options) {
112
+ let group = groups.find((group) => group.name === option.groupName);
113
+ if (!group) {
114
+ group = {
115
+ name: option.groupName,
116
+ options: [],
117
+ };
118
+ groups.push(group);
119
+ }
120
+ group.options.push(option);
121
+ }
122
+ }
123
+ else {
124
+ groups = [{
125
+ name: "Options",
126
+ options,
127
+ }];
128
+ }
129
+ let result = "";
130
+ for (const group of groups) {
131
+ result += this.generateOptionGroup(group);
132
+ }
133
+ return result;
134
+ }
135
+ generateOptionGroup(group) {
136
+ if (!group.options.length) {
137
+ return "";
138
+ }
139
+ const hasTypeDefinitions = !!group.options.find((option) => !!option.typeDefinition);
140
+ if (hasTypeDefinitions) {
141
+ return this.label(group.name ?? "Options") +
142
+ Table.from([
143
+ ...group.options.map((option) => [
144
+ option.flags.map((flag) => brightBlue(flag)).join(", "),
145
+ highlightArguments(option.typeDefinition || "", this.options.types),
146
+ red(bold("-")),
147
+ getDescription(option.description, !this.options.long),
148
+ this.generateHints(option),
149
+ ]),
150
+ ])
151
+ .padding([2, 2, 1, 2])
152
+ .indent(this.indent * 2)
153
+ .maxColWidth([60, 60, 1, 80, 60])
154
+ .toString() +
155
+ "\n";
156
+ }
157
+ return this.label(group.name ?? "Options") +
158
+ Table.from([
159
+ ...group.options.map((option) => [
160
+ option.flags.map((flag) => brightBlue(flag)).join(", "),
161
+ red(bold("-")),
162
+ getDescription(option.description, !this.options.long),
163
+ this.generateHints(option),
164
+ ]),
165
+ ])
166
+ .indent(this.indent * 2)
167
+ .maxColWidth([60, 1, 80, 60])
168
+ .padding([2, 1, 2])
169
+ .toString() +
170
+ "\n";
171
+ }
172
+ generateCommands() {
173
+ const commands = this.cmd.getCommands(false);
174
+ if (!commands.length) {
175
+ return "";
176
+ }
177
+ const hasTypeDefinitions = !!commands.find((command) => !!command.getArgsDefinition());
178
+ if (hasTypeDefinitions) {
179
+ return this.label("Commands") +
180
+ Table.from([
181
+ ...commands.map((command) => [
182
+ [command.getName(), ...command.getAliases()].map((name) => brightBlue(name)).join(", "),
183
+ highlightArguments(command.getArgsDefinition() || "", this.options.types),
184
+ red(bold("-")),
185
+ command.getShortDescription(),
186
+ ]),
187
+ ])
188
+ .indent(this.indent * 2)
189
+ .maxColWidth([60, 60, 1, 80])
190
+ .padding([2, 2, 1, 2])
191
+ .toString() +
192
+ "\n";
193
+ }
194
+ return this.label("Commands") +
195
+ Table.from([
196
+ ...commands.map((command) => [
197
+ [command.getName(), ...command.getAliases()].map((name) => brightBlue(name))
198
+ .join(", "),
199
+ red(bold("-")),
200
+ command.getShortDescription(),
201
+ ]),
202
+ ])
203
+ .maxColWidth([60, 1, 80])
204
+ .padding([2, 1, 2])
205
+ .indent(this.indent * 2)
206
+ .toString() +
207
+ "\n";
208
+ }
209
+ generateEnvironmentVariables() {
210
+ const envVars = this.cmd.getEnvVars(false);
211
+ if (!envVars.length) {
212
+ return "";
213
+ }
214
+ return this.label("Environment variables") +
215
+ Table.from([
216
+ ...envVars.map((envVar) => [
217
+ envVar.names.map((name) => brightBlue(name)).join(", "),
218
+ highlightArgumentDetails(envVar.details, this.options.types),
219
+ red(bold("-")),
220
+ this.options.long
221
+ ? dedent(envVar.description)
222
+ : envVar.description.trim().split("\n", 1)[0],
223
+ envVar.required ? `(${yellow(`required`)})` : "",
224
+ ]),
225
+ ])
226
+ .padding([2, 2, 1, 2])
227
+ .indent(this.indent * 2)
228
+ .maxColWidth([60, 60, 1, 80, 10])
229
+ .toString() +
230
+ "\n";
231
+ }
232
+ generateExamples() {
233
+ const examples = this.cmd.getExamples();
234
+ if (!examples.length) {
235
+ return "";
236
+ }
237
+ return this.label("Examples") +
238
+ Table.from(examples.map((example) => [
239
+ dim(bold(`${capitalize(example.name)}:`)),
240
+ dedent(example.description),
241
+ ]))
242
+ .padding(1)
243
+ .indent(this.indent * 2)
244
+ .maxColWidth(150)
245
+ .toString() +
246
+ "\n";
247
+ }
248
+ generateHints(option) {
249
+ if (!this.options.hints) {
250
+ return "";
251
+ }
252
+ const hints = [];
253
+ option.required && hints.push(yellow(`required`));
254
+ typeof option.default !== "undefined" && hints.push(bold(`Default: `) + inspect(option.default, this.options.colors));
255
+ option.depends?.length && hints.push(yellow(bold(`Depends: `)) +
256
+ italic(option.depends.map(getFlag).join(", ")));
257
+ option.conflicts?.length && hints.push(red(bold(`Conflicts: `)) +
258
+ italic(option.conflicts.map(getFlag).join(", ")));
259
+ const type = this.cmd.getType(option.args[0]?.type)?.handler;
260
+ if (type instanceof Type) {
261
+ const possibleValues = type.values?.(this.cmd, this.cmd.getParent());
262
+ if (possibleValues?.length) {
263
+ hints.push(bold(`Values: `) +
264
+ possibleValues.map((value) => inspect(value, this.options.colors)).join(", "));
265
+ }
266
+ }
267
+ if (hints.length) {
268
+ return `(${hints.join(", ")})`;
269
+ }
270
+ return "";
271
+ }
272
+ label(label) {
273
+ return "\n" +
274
+ " ".repeat(this.indent) + bold(`${label}:`) +
275
+ "\n\n";
276
+ }
277
+ }
278
+ function capitalize(string) {
279
+ return string?.charAt(0).toUpperCase() + string.slice(1) ?? "";
280
+ }
281
+ function inspect(value, colors) {
282
+ return dntShim.Deno.inspect(value,
283
+ // deno < 1.4.3 doesn't support the colors property.
284
+ { depth: 1, colors, trailingComma: false });
285
+ }
286
+ /**
287
+ * Colorize arguments string.
288
+ * @param argsDefinition Arguments definition: `<color1:string> <color2:string>`
289
+ * @param types Show types.
290
+ */
291
+ function highlightArguments(argsDefinition, types = true) {
292
+ if (!argsDefinition) {
293
+ return "";
294
+ }
295
+ return parseArgumentsDefinition(argsDefinition, false, true)
296
+ .map((arg) => typeof arg === "string" ? arg : highlightArgumentDetails(arg, types))
297
+ .join(" ");
298
+ }
299
+ /**
300
+ * Colorize argument string.
301
+ * @param arg Argument details.
302
+ * @param types Show types.
303
+ */
304
+ function highlightArgumentDetails(arg, types = true) {
305
+ let str = "";
306
+ str += yellow(arg.optionalValue ? "[" : "<");
307
+ let name = "";
308
+ name += arg.name;
309
+ if (arg.variadic) {
310
+ name += "...";
311
+ }
312
+ name = brightMagenta(name);
313
+ str += name;
314
+ if (types) {
315
+ str += yellow(":");
316
+ str += red(arg.type);
317
+ if (arg.list) {
318
+ str += green("[]");
319
+ }
320
+ }
321
+ str += yellow(arg.optionalValue ? "]" : ">");
322
+ return str;
323
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from "../command.js";
2
+ import { CommandType } from "../types/command.js";
3
+ /** Generates well formatted and colored help output for specified command. */
4
+ export declare class HelpCommand extends Command<void, void, void, [commandName?: CommandType]> {
5
+ constructor(cmd?: Command);
6
+ }