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 @@
1
+ export declare function distance(a: string, b: string): number;
@@ -0,0 +1,26 @@
1
+ export function distance(a, b) {
2
+ if (a.length == 0) {
3
+ return b.length;
4
+ }
5
+ if (b.length == 0) {
6
+ return a.length;
7
+ }
8
+ const matrix = [];
9
+ for (let i = 0; i <= b.length; i++) {
10
+ matrix[i] = [i];
11
+ }
12
+ for (let j = 0; j <= a.length; j++) {
13
+ matrix[0][j] = j;
14
+ }
15
+ for (let i = 1; i <= b.length; i++) {
16
+ for (let j = 1; j <= a.length; j++) {
17
+ if (b.charAt(i - 1) == a.charAt(j - 1)) {
18
+ matrix[i][j] = matrix[i - 1][j - 1];
19
+ }
20
+ else {
21
+ matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
22
+ }
23
+ }
24
+ }
25
+ return matrix[b.length][a.length];
26
+ }
@@ -0,0 +1,76 @@
1
+ import type { Command } from "./command.js";
2
+ import { EnvVar } from "./types.js";
3
+ export declare class CommandError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ export interface ValidationErrorOptions {
7
+ exitCode?: number;
8
+ }
9
+ export declare class ValidationError extends CommandError {
10
+ readonly exitCode: number;
11
+ cmd?: Command;
12
+ constructor(message: string, { exitCode }?: ValidationErrorOptions);
13
+ }
14
+ export declare class DuplicateOptionNameError extends CommandError {
15
+ constructor(name: string);
16
+ }
17
+ export declare class MissingCommandNameError extends CommandError {
18
+ constructor();
19
+ }
20
+ export declare class DuplicateCommandNameError extends CommandError {
21
+ constructor(name: string);
22
+ }
23
+ export declare class DuplicateCommandAliasError extends CommandError {
24
+ constructor(alias: string);
25
+ }
26
+ export declare class CommandNotFoundError extends CommandError {
27
+ constructor(name: string, commands: Array<Command>, excluded?: Array<string>);
28
+ }
29
+ export declare class DuplicateTypeError extends CommandError {
30
+ constructor(name: string);
31
+ }
32
+ export declare class DuplicateCompletionError extends CommandError {
33
+ constructor(name: string);
34
+ }
35
+ export declare class DuplicateExampleError extends CommandError {
36
+ constructor(name: string);
37
+ }
38
+ export declare class DuplicateEnvVarError extends CommandError {
39
+ constructor(name: string);
40
+ }
41
+ export declare class MissingRequiredEnvVarError extends ValidationError {
42
+ constructor(envVar: EnvVar);
43
+ }
44
+ export declare class TooManyEnvVarValuesError extends CommandError {
45
+ constructor(name: string);
46
+ }
47
+ export declare class UnexpectedOptionalEnvVarValueError extends CommandError {
48
+ constructor(name: string);
49
+ }
50
+ export declare class UnexpectedVariadicEnvVarValueError extends CommandError {
51
+ constructor(name: string);
52
+ }
53
+ export declare class DefaultCommandNotFoundError extends CommandError {
54
+ constructor(name: string, commands: Array<Command>);
55
+ }
56
+ export declare class CommandExecutableNotFoundError extends CommandError {
57
+ constructor(name: string);
58
+ }
59
+ export declare class UnknownCompletionCommandError extends CommandError {
60
+ constructor(name: string, commands: Array<Command>);
61
+ }
62
+ export declare class UnknownCommandError extends ValidationError {
63
+ constructor(name: string, commands: Array<Command>, excluded?: Array<string>);
64
+ }
65
+ export declare class NoArgumentsAllowedError extends ValidationError {
66
+ constructor(name: string);
67
+ }
68
+ export declare class MissingArgumentsError extends ValidationError {
69
+ constructor(names: Array<string>);
70
+ }
71
+ export declare class MissingArgumentError extends ValidationError {
72
+ constructor(name: string);
73
+ }
74
+ export declare class TooManyArgumentsError extends ValidationError {
75
+ constructor(args: Array<string>);
76
+ }
@@ -0,0 +1,154 @@
1
+ import { didYouMeanCommand } from "./_utils.js";
2
+ import { getFlag } from "../flags/_utils.js";
3
+ export class CommandError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ Object.setPrototypeOf(this, CommandError.prototype);
7
+ }
8
+ }
9
+ export class ValidationError extends CommandError {
10
+ constructor(message, { exitCode } = {}) {
11
+ super(message);
12
+ Object.defineProperty(this, "exitCode", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "cmd", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.setPrototypeOf(this, ValidationError.prototype);
25
+ this.exitCode = exitCode ?? 1;
26
+ }
27
+ }
28
+ export class DuplicateOptionNameError extends CommandError {
29
+ constructor(name) {
30
+ super(`Option with name "${getFlag(name)}" already exists.`);
31
+ Object.setPrototypeOf(this, DuplicateOptionNameError.prototype);
32
+ }
33
+ }
34
+ export class MissingCommandNameError extends CommandError {
35
+ constructor() {
36
+ super("Missing command name.");
37
+ Object.setPrototypeOf(this, MissingCommandNameError.prototype);
38
+ }
39
+ }
40
+ export class DuplicateCommandNameError extends CommandError {
41
+ constructor(name) {
42
+ super(`Duplicate command name "${name}".`);
43
+ Object.setPrototypeOf(this, DuplicateCommandNameError.prototype);
44
+ }
45
+ }
46
+ export class DuplicateCommandAliasError extends CommandError {
47
+ constructor(alias) {
48
+ super(`Duplicate command alias "${alias}".`);
49
+ Object.setPrototypeOf(this, DuplicateCommandAliasError.prototype);
50
+ }
51
+ }
52
+ export class CommandNotFoundError extends CommandError {
53
+ constructor(name, commands, excluded) {
54
+ super(`Unknown command "${name}".${didYouMeanCommand(name, commands, excluded)}`);
55
+ Object.setPrototypeOf(this, CommandNotFoundError.prototype);
56
+ }
57
+ }
58
+ export class DuplicateTypeError extends CommandError {
59
+ constructor(name) {
60
+ super(`Type with name "${name}" already exists.`);
61
+ Object.setPrototypeOf(this, DuplicateTypeError.prototype);
62
+ }
63
+ }
64
+ export class DuplicateCompletionError extends CommandError {
65
+ constructor(name) {
66
+ super(`Completion with name "${name}" already exists.`);
67
+ Object.setPrototypeOf(this, DuplicateCompletionError.prototype);
68
+ }
69
+ }
70
+ export class DuplicateExampleError extends CommandError {
71
+ constructor(name) {
72
+ super(`Example with name "${name}" already exists.`);
73
+ Object.setPrototypeOf(this, DuplicateExampleError.prototype);
74
+ }
75
+ }
76
+ export class DuplicateEnvVarError extends CommandError {
77
+ constructor(name) {
78
+ super(`Environment variable with name "${name}" already exists.`);
79
+ Object.setPrototypeOf(this, DuplicateEnvVarError.prototype);
80
+ }
81
+ }
82
+ export class MissingRequiredEnvVarError extends ValidationError {
83
+ constructor(envVar) {
84
+ super(`Missing required environment variable "${envVar.names[0]}".`);
85
+ Object.setPrototypeOf(this, MissingRequiredEnvVarError.prototype);
86
+ }
87
+ }
88
+ export class TooManyEnvVarValuesError extends CommandError {
89
+ constructor(name) {
90
+ super(`An environment variable can only have one value, but "${name}" has more than one.`);
91
+ Object.setPrototypeOf(this, TooManyEnvVarValuesError.prototype);
92
+ }
93
+ }
94
+ export class UnexpectedOptionalEnvVarValueError extends CommandError {
95
+ constructor(name) {
96
+ super(`An environment variable cannot have an optional value, but "${name}" is defined as optional.`);
97
+ Object.setPrototypeOf(this, UnexpectedOptionalEnvVarValueError.prototype);
98
+ }
99
+ }
100
+ export class UnexpectedVariadicEnvVarValueError extends CommandError {
101
+ constructor(name) {
102
+ super(`An environment variable cannot have an variadic value, but "${name}" is defined as variadic.`);
103
+ Object.setPrototypeOf(this, UnexpectedVariadicEnvVarValueError.prototype);
104
+ }
105
+ }
106
+ export class DefaultCommandNotFoundError extends CommandError {
107
+ constructor(name, commands) {
108
+ super(`Default command "${name}" not found.${didYouMeanCommand(name, commands)}`);
109
+ Object.setPrototypeOf(this, DefaultCommandNotFoundError.prototype);
110
+ }
111
+ }
112
+ export class CommandExecutableNotFoundError extends CommandError {
113
+ constructor(name) {
114
+ super(`Command executable not found: ${name}`);
115
+ Object.setPrototypeOf(this, CommandExecutableNotFoundError.prototype);
116
+ }
117
+ }
118
+ export class UnknownCompletionCommandError extends CommandError {
119
+ constructor(name, commands) {
120
+ super(`Auto-completion failed. Unknown command "${name}".${didYouMeanCommand(name, commands)}`);
121
+ Object.setPrototypeOf(this, UnknownCompletionCommandError.prototype);
122
+ }
123
+ }
124
+ /* Validation errors. */
125
+ export class UnknownCommandError extends ValidationError {
126
+ constructor(name, commands, excluded) {
127
+ super(`Unknown command "${name}".${didYouMeanCommand(name, commands, excluded)}`);
128
+ Object.setPrototypeOf(this, UnknownCommandError.prototype);
129
+ }
130
+ }
131
+ export class NoArgumentsAllowedError extends ValidationError {
132
+ constructor(name) {
133
+ super(`No arguments allowed for command "${name}".`);
134
+ Object.setPrototypeOf(this, NoArgumentsAllowedError.prototype);
135
+ }
136
+ }
137
+ export class MissingArgumentsError extends ValidationError {
138
+ constructor(names) {
139
+ super(`Missing argument(s): ${names.join(", ")}`);
140
+ Object.setPrototypeOf(this, MissingArgumentsError.prototype);
141
+ }
142
+ }
143
+ export class MissingArgumentError extends ValidationError {
144
+ constructor(name) {
145
+ super(`Missing argument: ${name}`);
146
+ Object.setPrototypeOf(this, MissingArgumentError.prototype);
147
+ }
148
+ }
149
+ export class TooManyArgumentsError extends ValidationError {
150
+ constructor(args) {
151
+ super(`Too many arguments: ${args.join(" ")}`);
152
+ Object.setPrototypeOf(this, TooManyArgumentsError.prototype);
153
+ }
154
+ }
@@ -0,0 +1,32 @@
1
+ import type { Command } from "./command.js";
2
+ import type { Argument } from "./types.js";
3
+ export declare function didYouMeanCommand(command: string, commands: Array<Command>, excludes?: Array<string>): string;
4
+ interface SplitArgumentsResult {
5
+ flags: string[];
6
+ typeDefinition: string;
7
+ equalsSign: boolean;
8
+ }
9
+ /**
10
+ * Split options and arguments.
11
+ * @param args Arguments definition: `--color, -c <color1:string> <color2:string>`
12
+ *
13
+ * For example: `-c, --color <color1:string> <color2:string>`
14
+ *
15
+ * Will result in:
16
+ * ```
17
+ * {
18
+ * flags: [ "-c", "--color" ],
19
+ * typeDefinition: "<color1:string> <color2:string>"
20
+ * }
21
+ * ```
22
+ */
23
+ export declare function splitArguments(args: string): SplitArgumentsResult;
24
+ /**
25
+ * Parse arguments string.
26
+ * @param argsDefinition Arguments definition: `<color1:string> <color2:string>`
27
+ */
28
+ export declare function parseArgumentsDefinition<T extends boolean>(argsDefinition: string, validate: boolean, all: true): Array<Argument | string>;
29
+ export declare function parseArgumentsDefinition<T extends boolean>(argsDefinition: string, validate?: boolean, all?: false): Array<Argument>;
30
+ export declare function dedent(str: string): string;
31
+ export declare function getDescription(description: string, short?: boolean): string;
32
+ export {};
@@ -0,0 +1,105 @@
1
+ import { UnexpectedArgumentAfterVariadicArgumentError, UnexpectedRequiredArgumentError, } from "../flags/_errors.js";
2
+ import { didYouMean } from "../flags/_utils.js";
3
+ import { OptionType } from "../flags/deprecated.js";
4
+ export function didYouMeanCommand(command, commands, excludes = []) {
5
+ const commandNames = commands
6
+ .map((command) => command.getName())
7
+ .filter((command) => !excludes.includes(command));
8
+ return didYouMean(" Did you mean command", command, commandNames);
9
+ }
10
+ const ARGUMENT_REGEX = /^[<\[].+[\]>]$/;
11
+ const ARGUMENT_DETAILS_REGEX = /[<\[:>\]]/;
12
+ /**
13
+ * Split options and arguments.
14
+ * @param args Arguments definition: `--color, -c <color1:string> <color2:string>`
15
+ *
16
+ * For example: `-c, --color <color1:string> <color2:string>`
17
+ *
18
+ * Will result in:
19
+ * ```
20
+ * {
21
+ * flags: [ "-c", "--color" ],
22
+ * typeDefinition: "<color1:string> <color2:string>"
23
+ * }
24
+ * ```
25
+ */
26
+ export function splitArguments(args) {
27
+ const parts = args.trim().split(/[, =] */g);
28
+ const typeParts = [];
29
+ while (parts[parts.length - 1] &&
30
+ ARGUMENT_REGEX.test(parts[parts.length - 1])) {
31
+ typeParts.unshift(parts.pop());
32
+ }
33
+ const typeDefinition = typeParts.join(" ");
34
+ return { flags: parts, typeDefinition, equalsSign: args.includes("=") };
35
+ }
36
+ export function parseArgumentsDefinition(argsDefinition, validate = true, all) {
37
+ const argumentDetails = [];
38
+ let hasOptional = false;
39
+ let hasVariadic = false;
40
+ const parts = argsDefinition.split(/ +/);
41
+ for (const arg of parts) {
42
+ if (validate && hasVariadic) {
43
+ throw new UnexpectedArgumentAfterVariadicArgumentError(arg);
44
+ }
45
+ const parts = arg.split(ARGUMENT_DETAILS_REGEX);
46
+ if (!parts[1]) {
47
+ if (all) {
48
+ argumentDetails.push(parts[0]);
49
+ }
50
+ continue;
51
+ }
52
+ const type = parts[2] || OptionType.STRING;
53
+ const details = {
54
+ optionalValue: arg[0] === "[",
55
+ requiredValue: arg[0] === "<",
56
+ name: parts[1],
57
+ action: parts[3] || type,
58
+ variadic: false,
59
+ list: type ? arg.indexOf(type + "[]") !== -1 : false,
60
+ type,
61
+ };
62
+ if (validate && !details.optionalValue && hasOptional) {
63
+ throw new UnexpectedRequiredArgumentError(details.name);
64
+ }
65
+ if (arg[0] === "[") {
66
+ hasOptional = true;
67
+ }
68
+ if (details.name.length > 3) {
69
+ const istVariadicLeft = details.name.slice(0, 3) === "...";
70
+ const istVariadicRight = details.name.slice(-3) === "...";
71
+ hasVariadic = details.variadic = istVariadicLeft || istVariadicRight;
72
+ if (istVariadicLeft) {
73
+ details.name = details.name.slice(3);
74
+ }
75
+ else if (istVariadicRight) {
76
+ details.name = details.name.slice(0, -3);
77
+ }
78
+ }
79
+ argumentDetails.push(details);
80
+ }
81
+ return argumentDetails;
82
+ }
83
+ export function dedent(str) {
84
+ const lines = str.split(/\r?\n|\r/g);
85
+ let text = "";
86
+ let indent = 0;
87
+ for (const line of lines) {
88
+ if (text || line.trim()) {
89
+ if (!text) {
90
+ text = line.trimStart();
91
+ indent = line.length - text.length;
92
+ }
93
+ else {
94
+ text += line.slice(indent);
95
+ }
96
+ text += "\n";
97
+ }
98
+ }
99
+ return text.trimEnd();
100
+ }
101
+ export function getDescription(description, short) {
102
+ return short
103
+ ? description.trim().split("\n", 1)[0].trim()
104
+ : dedent(description);
105
+ }