@shell-shock/core 0.5.0 → 0.6.0

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 (59) hide show
  1. package/README.md +1 -1
  2. package/dist/components/docs.d.cts +5 -5
  3. package/dist/components/index.cjs +1 -1
  4. package/dist/components/index.d.cts +2 -2
  5. package/dist/components/index.d.mts +2 -2
  6. package/dist/components/index.mjs +2 -2
  7. package/dist/components/options-parser-logic.cjs +17 -22
  8. package/dist/components/options-parser-logic.cjs.map +1 -1
  9. package/dist/components/options-parser-logic.d.cts +4 -8
  10. package/dist/components/options-parser-logic.d.cts.map +1 -1
  11. package/dist/components/options-parser-logic.d.mts +4 -8
  12. package/dist/components/options-parser-logic.d.mts.map +1 -1
  13. package/dist/components/options-parser-logic.mjs +18 -23
  14. package/dist/components/options-parser-logic.mjs.map +1 -1
  15. package/dist/components/usage.cjs +1 -1
  16. package/dist/components/usage.cjs.map +1 -1
  17. package/dist/components/usage.d.cts +2 -2
  18. package/dist/components/usage.d.mts +2 -2
  19. package/dist/components/usage.mjs +2 -2
  20. package/dist/components/usage.mjs.map +1 -1
  21. package/dist/helpers/resolve-command.cjs +20 -31
  22. package/dist/helpers/resolve-command.cjs.map +1 -1
  23. package/dist/helpers/resolve-command.mjs +21 -32
  24. package/dist/helpers/resolve-command.mjs.map +1 -1
  25. package/dist/helpers/validations.cjs +20 -20
  26. package/dist/helpers/validations.cjs.map +1 -1
  27. package/dist/helpers/validations.mjs +21 -21
  28. package/dist/helpers/validations.mjs.map +1 -1
  29. package/dist/index.d.cts +2 -2
  30. package/dist/index.d.mts +2 -2
  31. package/dist/plugin-utils/context-helpers.cjs +106 -5
  32. package/dist/plugin-utils/context-helpers.cjs.map +1 -1
  33. package/dist/plugin-utils/context-helpers.d.cts +89 -3
  34. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  35. package/dist/plugin-utils/context-helpers.d.mts +89 -3
  36. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  37. package/dist/plugin-utils/context-helpers.mjs +100 -4
  38. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  39. package/dist/plugin-utils/get-command-tree.cjs +1 -1
  40. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  41. package/dist/plugin-utils/get-command-tree.mjs +2 -2
  42. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  43. package/dist/plugin-utils/index.cjs +7 -2
  44. package/dist/plugin-utils/index.d.cts +2 -2
  45. package/dist/plugin-utils/index.d.mts +2 -2
  46. package/dist/plugin-utils/index.mjs +2 -2
  47. package/dist/plugin.cjs +1 -1
  48. package/dist/plugin.cjs.map +1 -1
  49. package/dist/plugin.d.cts.map +1 -1
  50. package/dist/plugin.d.mts.map +1 -1
  51. package/dist/plugin.mjs +2 -2
  52. package/dist/plugin.mjs.map +1 -1
  53. package/dist/types/command.d.cts +20 -3
  54. package/dist/types/command.d.cts.map +1 -1
  55. package/dist/types/command.d.mts +20 -3
  56. package/dist/types/command.d.mts.map +1 -1
  57. package/dist/types/index.d.cts +2 -2
  58. package/dist/types/index.d.mts +2 -2
  59. package/package.json +6 -6
@@ -36,7 +36,7 @@ function getAppName(context) {
36
36
  * @returns The application title in title-case format.
37
37
  */
38
38
  function getAppTitle(context) {
39
- return (0, __stryke_string_format_title_case.titleCase)(context.config.name || getAppName(context));
39
+ return context.config.title || (0, __stryke_string_format_title_case.titleCase)(context.config.name || getAppName(context));
40
40
  }
41
41
  /**
42
42
  * Retrieves the application description from the context and configuration.
@@ -59,28 +59,129 @@ function getAppBin(context) {
59
59
  /**
60
60
  * Determines if a given command path segment is variable (enclosed in square brackets).
61
61
  *
62
+ * @example
63
+ * ```typescript
64
+ * isDynamicPathSegment("[user]"); // true
65
+ * isDynamicPathSegment("user"); // false
66
+ * isDynamicPathSegment("[[...user]]"); // true
67
+ * isDynamicPathSegment("[...user]"); // true
68
+ * ```
69
+ *
62
70
  * @param path - The command path segment to check.
63
71
  * @returns True if the path is variable, false otherwise.
64
72
  */
65
- function isPositionalCommandOption(path) {
73
+ function isDynamicPathSegment(path) {
66
74
  return path.startsWith("[") && path.endsWith("]");
67
75
  }
68
76
  /**
77
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * isOptionalCatchAllPathSegment("[[...user]]"); // true
82
+ * isOptionalCatchAllPathSegment("[...user]"); // false
83
+ * isOptionalCatchAllPathSegment("[user]"); // false
84
+ * ```
85
+ *
86
+ * @param path - The command path segment to check.
87
+ * @returns True if the path is an optional catch-all segment, false otherwise.
88
+ */
89
+ function isOptionalCatchAllPathSegment(path) {
90
+ return path.startsWith("[[...") && path.endsWith("]]");
91
+ }
92
+ /**
93
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * isCatchAllPathSegment("[[...user]]"); // true
98
+ * isCatchAllPathSegment("[...user]"); // true
99
+ * isCatchAllPathSegment("[user]"); // false
100
+ * ```
101
+ *
102
+ * @param path - The command path segment to check.
103
+ * @returns True if the path is a catch-all segment, false otherwise.
104
+ */
105
+ function isCatchAllPathSegment(path) {
106
+ return path.startsWith("[...") && path.endsWith("]") || isOptionalCatchAllPathSegment(path);
107
+ }
108
+ /**
69
109
  * Extracts the variable name from a command path segment by removing enclosing square brackets.
70
110
  *
111
+ * @example
112
+ * ```typescript
113
+ * getDynamicPathSegmentName("[user]"); // "user"
114
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
115
+ * getDynamicPathSegmentName("[...user]"); // "user"
116
+ * ```
117
+ *
71
118
  * @param path - The command path segment.
72
119
  * @returns The variable name without square brackets.
73
120
  */
74
- function getPositionalCommandOptionName(path) {
121
+ function getDynamicPathSegmentName(path) {
75
122
  return path.replaceAll(/^\[+(?:\.\.\.)*/g, "").replaceAll(/\]+$/g, "");
76
123
  }
124
+ /**
125
+ * Determines if a given command path segment is a path segment group (enclosed in parentheses).
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * isPathSegmentGroup("(user)"); // true
130
+ * isPathSegmentGroup("[[...user]]"); // false
131
+ * isPathSegmentGroup("[...user]"); // false
132
+ * isPathSegmentGroup("[user]"); // false
133
+ * isPathSegmentGroup("user"); // false
134
+ * ```
135
+ *
136
+ * @param path - The command path segment to check.
137
+ * @returns True if the path is a path segment group, false otherwise.
138
+ */
139
+ function isPathSegmentGroup(path) {
140
+ return path.startsWith("(") && path.endsWith(")");
141
+ }
142
+ /**
143
+ * Extracts the group name from a command path segment by removing enclosing parentheses.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * getPathSegmentGroupName("(admin)"); // "admin"
148
+ * getPathSegmentGroupName("((group))"); // "group"
149
+ * ```
150
+ *
151
+ * @param path - The command path segment.
152
+ * @returns The group name without parentheses.
153
+ */
154
+ function getPathSegmentGroupName(path) {
155
+ return path.replaceAll(/^\(+/g, "").replaceAll(/\)+$/g, "");
156
+ }
157
+ /**
158
+ * Extracts the variable name from a command path segment by removing enclosing square brackets.
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * getDynamicPathSegmentName("[user]"); // "user"
163
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
164
+ * getDynamicPathSegmentName("[...user]"); // "user"
165
+ * ```
166
+ *
167
+ * @param path - The command path segment.
168
+ * @returns The variable name without square brackets.
169
+ */
170
+ function getPathSegmentName(path) {
171
+ return getPathSegmentGroupName(getDynamicPathSegmentName(path));
172
+ }
77
173
 
78
174
  //#endregion
79
175
  exports.getAppBin = getAppBin;
80
176
  exports.getAppDescription = getAppDescription;
81
177
  exports.getAppName = getAppName;
82
178
  exports.getAppTitle = getAppTitle;
83
- exports.getPositionalCommandOptionName = getPositionalCommandOptionName;
84
- exports.isPositionalCommandOption = isPositionalCommandOption;
179
+ exports.getDynamicPathSegmentName = getDynamicPathSegmentName;
180
+ exports.getPathSegmentGroupName = getPathSegmentGroupName;
181
+ exports.getPathSegmentName = getPathSegmentName;
182
+ exports.isCatchAllPathSegment = isCatchAllPathSegment;
183
+ exports.isDynamicPathSegment = isDynamicPathSegment;
184
+ exports.isOptionalCatchAllPathSegment = isOptionalCatchAllPathSegment;
185
+ exports.isPathSegmentGroup = isPathSegmentGroup;
85
186
  exports.sortArgAliases = sortArgAliases;
86
187
  //# sourceMappingURL=context-helpers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.cjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","getAppDescription","description","getAppBin","Object","keys","isPositionalCommandOption","path","startsWith","endsWith","getPositionalCommandOptionName","replaceAll"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return titleCase(context.config.name || getAppName(context));\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isPositionalCommandOption(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPositionalCommandOptionName(path: string): string {\n return path.replaceAll(/^\\[+(?:\\.\\.\\.)*/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,6DACFF,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,yDAChBU,QAAQC,OAAOE,IAAI,GAAI,uDACrBH,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,qDAAaX,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,yDAAiBhB,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,yDAAiBA,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAS9D,SAAgBS,kBACdT,SACQ;AACR,QACEA,QAAQC,OAAOS,eACfV,QAAQM,aAAaI,eACrB,OAAOF,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBW,UAAUX,SAA0B;AAClD,4DAAmBA,QAAQC,OAAOE,IAAI,GAClCS,OAAOC,KAAKb,QAAQC,OAAOE,IAAI,CAAC,sDACtBJ,WAAWC,QAAQ,CAAC;;;;;;;;AASpC,SAAgBc,0BAA0BC,MAAuB;AAC/D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;AASnD,SAAgBC,+BAA+BH,MAAsB;AACnE,QAAOA,KAAKI,WAAW,oBAAoB,GAAG,CAACA,WAAW,SAAS,GAAG"}
1
+ {"version":3,"file":"context-helpers.cjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","title","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","isOptionalCatchAllPathSegment","isCatchAllPathSegment","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return (\n context.config.title ||\n titleCase(context.config.name || getAppName(context))\n );\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * isDynamicPathSegment(\"[[...user]]\"); // true\n * isDynamicPathSegment(\"[...user]\"); // true\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).\n *\n * @example\n * ```typescript\n * isOptionalCatchAllPathSegment(\"[[...user]]\"); // true\n * isOptionalCatchAllPathSegment(\"[...user]\"); // false\n * isOptionalCatchAllPathSegment(\"[user]\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is an optional catch-all segment, false otherwise.\n */\nexport function isOptionalCatchAllPathSegment(path: string): boolean {\n return path.startsWith(\"[[...\") && path.endsWith(\"]]\");\n}\n\n/**\n * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).\n *\n * @example\n * ```typescript\n * isCatchAllPathSegment(\"[[...user]]\"); // true\n * isCatchAllPathSegment(\"[...user]\"); // true\n * isCatchAllPathSegment(\"[user]\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a catch-all segment, false otherwise.\n */\nexport function isCatchAllPathSegment(path: string): boolean {\n return (\n (path.startsWith(\"[...\") && path.endsWith(\"]\")) ||\n isOptionalCatchAllPathSegment(path)\n );\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * getDynamicPathSegmentName(\"[[...user]]\"); // \"user\"\n * getDynamicPathSegmentName(\"[...user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+(?:\\.\\.\\.)*/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[[...user]]\"); // false\n * isPathSegmentGroup(\"[...user]\"); // false\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return path.startsWith(\"(\") && path.endsWith(\")\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path.replaceAll(/^\\(+/g, \"\").replaceAll(/\\)+$/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * getDynamicPathSegmentName(\"[[...user]]\"); // \"user\"\n * getDynamicPathSegmentName(\"[...user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,6DACFF,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,yDAChBU,QAAQC,OAAOE,IAAI,GAAI,uDACrBH,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,qDAAaX,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,yDAAiBhB,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QACEA,QAAQC,OAAOQ,0DACLT,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAUzD,SAAgBU,kBACdV,SACQ;AACR,QACEA,QAAQC,OAAOU,eACfX,QAAQM,aAAaK,eACrB,OAAOH,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBY,UAAUZ,SAA0B;AAClD,4DAAmBA,QAAQC,OAAOE,IAAI,GAClCU,OAAOC,KAAKd,QAAQC,OAAOE,IAAI,CAAC,sDACtBJ,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;;;AAiBpC,SAAgBe,qBAAqBC,MAAuB;AAC1D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;;;AAgBnD,SAAgBC,8BAA8BH,MAAuB;AACnE,QAAOA,KAAKC,WAAW,QAAQ,IAAID,KAAKE,SAAS,KAAK;;;;;;;;;;;;;;;AAgBxD,SAAgBE,sBAAsBJ,MAAuB;AAC3D,QACGA,KAAKC,WAAW,OAAO,IAAID,KAAKE,SAAS,IAAI,IAC9CC,8BAA8BH,KAAK;;;;;;;;;;;;;;;AAiBvC,SAAgBK,0BAA0BL,MAAsB;AAC9D,QAAOA,KAAKM,WAAW,oBAAoB,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;;;AAkBxE,SAAgBC,mBAAmBP,MAAuB;AACxD,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;;AAenD,SAAgBM,wBAAwBR,MAAsB;AAC5D,QAAOA,KAAKM,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBG,mBAAmBT,MAAsB;AACvD,QAAOQ,wBAAwBH,0BAA0BL,KAAK,CAAC"}
@@ -42,17 +42,103 @@ declare function getAppBin(context: Context): string;
42
42
  /**
43
43
  * Determines if a given command path segment is variable (enclosed in square brackets).
44
44
  *
45
+ * @example
46
+ * ```typescript
47
+ * isDynamicPathSegment("[user]"); // true
48
+ * isDynamicPathSegment("user"); // false
49
+ * isDynamicPathSegment("[[...user]]"); // true
50
+ * isDynamicPathSegment("[...user]"); // true
51
+ * ```
52
+ *
45
53
  * @param path - The command path segment to check.
46
54
  * @returns True if the path is variable, false otherwise.
47
55
  */
48
- declare function isPositionalCommandOption(path: string): boolean;
56
+ declare function isDynamicPathSegment(path: string): boolean;
57
+ /**
58
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * isOptionalCatchAllPathSegment("[[...user]]"); // true
63
+ * isOptionalCatchAllPathSegment("[...user]"); // false
64
+ * isOptionalCatchAllPathSegment("[user]"); // false
65
+ * ```
66
+ *
67
+ * @param path - The command path segment to check.
68
+ * @returns True if the path is an optional catch-all segment, false otherwise.
69
+ */
70
+ declare function isOptionalCatchAllPathSegment(path: string): boolean;
71
+ /**
72
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * isCatchAllPathSegment("[[...user]]"); // true
77
+ * isCatchAllPathSegment("[...user]"); // true
78
+ * isCatchAllPathSegment("[user]"); // false
79
+ * ```
80
+ *
81
+ * @param path - The command path segment to check.
82
+ * @returns True if the path is a catch-all segment, false otherwise.
83
+ */
84
+ declare function isCatchAllPathSegment(path: string): boolean;
49
85
  /**
50
86
  * Extracts the variable name from a command path segment by removing enclosing square brackets.
51
87
  *
88
+ * @example
89
+ * ```typescript
90
+ * getDynamicPathSegmentName("[user]"); // "user"
91
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
92
+ * getDynamicPathSegmentName("[...user]"); // "user"
93
+ * ```
94
+ *
95
+ * @param path - The command path segment.
96
+ * @returns The variable name without square brackets.
97
+ */
98
+ declare function getDynamicPathSegmentName(path: string): string;
99
+ /**
100
+ * Determines if a given command path segment is a path segment group (enclosed in parentheses).
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * isPathSegmentGroup("(user)"); // true
105
+ * isPathSegmentGroup("[[...user]]"); // false
106
+ * isPathSegmentGroup("[...user]"); // false
107
+ * isPathSegmentGroup("[user]"); // false
108
+ * isPathSegmentGroup("user"); // false
109
+ * ```
110
+ *
111
+ * @param path - The command path segment to check.
112
+ * @returns True if the path is a path segment group, false otherwise.
113
+ */
114
+ declare function isPathSegmentGroup(path: string): boolean;
115
+ /**
116
+ * Extracts the group name from a command path segment by removing enclosing parentheses.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * getPathSegmentGroupName("(admin)"); // "admin"
121
+ * getPathSegmentGroupName("((group))"); // "group"
122
+ * ```
123
+ *
124
+ * @param path - The command path segment.
125
+ * @returns The group name without parentheses.
126
+ */
127
+ declare function getPathSegmentGroupName(path: string): string;
128
+ /**
129
+ * Extracts the variable name from a command path segment by removing enclosing square brackets.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * getDynamicPathSegmentName("[user]"); // "user"
134
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
135
+ * getDynamicPathSegmentName("[...user]"); // "user"
136
+ * ```
137
+ *
52
138
  * @param path - The command path segment.
53
139
  * @returns The variable name without square brackets.
54
140
  */
55
- declare function getPositionalCommandOptionName(path: string): string;
141
+ declare function getPathSegmentName(path: string): string;
56
142
  //#endregion
57
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases };
143
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isCatchAllPathSegment, isDynamicPathSegment, isOptionalCatchAllPathSegment, isPathSegmentGroup, sortArgAliases };
58
144
  //# sourceMappingURL=context-helpers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAUgB,iBAtDA,cAAA,CAuDL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAYA;AAUA;;;;;iBA1EgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAUzC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;iBAYnB,yBAAA;;;;;;;iBAUA,8BAAA"}
1
+ {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAoBA;AAiBA;AAiBA;AAoBA;AAmBA;AAgBA;AAiBgB,iBArLA,UAAA,CAqLkB,OAAA,EArLE,iBAqLF,GArLsB,OAqLtB,CAAA,EAAA,MAAA;;;;;;;iBA3JlB,WAAA,UAAqB,oBAAoB;;;;;;;iBAazC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;;;iBAoBnB,oBAAA;;;;;;;;;;;;;;iBAiBA,6BAAA;;;;;;;;;;;;;;iBAiBA,qBAAA;;;;;;;;;;;;;;iBAoBA,yBAAA;;;;;;;;;;;;;;;;iBAmBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA"}
@@ -42,17 +42,103 @@ declare function getAppBin(context: Context): string;
42
42
  /**
43
43
  * Determines if a given command path segment is variable (enclosed in square brackets).
44
44
  *
45
+ * @example
46
+ * ```typescript
47
+ * isDynamicPathSegment("[user]"); // true
48
+ * isDynamicPathSegment("user"); // false
49
+ * isDynamicPathSegment("[[...user]]"); // true
50
+ * isDynamicPathSegment("[...user]"); // true
51
+ * ```
52
+ *
45
53
  * @param path - The command path segment to check.
46
54
  * @returns True if the path is variable, false otherwise.
47
55
  */
48
- declare function isPositionalCommandOption(path: string): boolean;
56
+ declare function isDynamicPathSegment(path: string): boolean;
57
+ /**
58
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * isOptionalCatchAllPathSegment("[[...user]]"); // true
63
+ * isOptionalCatchAllPathSegment("[...user]"); // false
64
+ * isOptionalCatchAllPathSegment("[user]"); // false
65
+ * ```
66
+ *
67
+ * @param path - The command path segment to check.
68
+ * @returns True if the path is an optional catch-all segment, false otherwise.
69
+ */
70
+ declare function isOptionalCatchAllPathSegment(path: string): boolean;
71
+ /**
72
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * isCatchAllPathSegment("[[...user]]"); // true
77
+ * isCatchAllPathSegment("[...user]"); // true
78
+ * isCatchAllPathSegment("[user]"); // false
79
+ * ```
80
+ *
81
+ * @param path - The command path segment to check.
82
+ * @returns True if the path is a catch-all segment, false otherwise.
83
+ */
84
+ declare function isCatchAllPathSegment(path: string): boolean;
49
85
  /**
50
86
  * Extracts the variable name from a command path segment by removing enclosing square brackets.
51
87
  *
88
+ * @example
89
+ * ```typescript
90
+ * getDynamicPathSegmentName("[user]"); // "user"
91
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
92
+ * getDynamicPathSegmentName("[...user]"); // "user"
93
+ * ```
94
+ *
95
+ * @param path - The command path segment.
96
+ * @returns The variable name without square brackets.
97
+ */
98
+ declare function getDynamicPathSegmentName(path: string): string;
99
+ /**
100
+ * Determines if a given command path segment is a path segment group (enclosed in parentheses).
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * isPathSegmentGroup("(user)"); // true
105
+ * isPathSegmentGroup("[[...user]]"); // false
106
+ * isPathSegmentGroup("[...user]"); // false
107
+ * isPathSegmentGroup("[user]"); // false
108
+ * isPathSegmentGroup("user"); // false
109
+ * ```
110
+ *
111
+ * @param path - The command path segment to check.
112
+ * @returns True if the path is a path segment group, false otherwise.
113
+ */
114
+ declare function isPathSegmentGroup(path: string): boolean;
115
+ /**
116
+ * Extracts the group name from a command path segment by removing enclosing parentheses.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * getPathSegmentGroupName("(admin)"); // "admin"
121
+ * getPathSegmentGroupName("((group))"); // "group"
122
+ * ```
123
+ *
124
+ * @param path - The command path segment.
125
+ * @returns The group name without parentheses.
126
+ */
127
+ declare function getPathSegmentGroupName(path: string): string;
128
+ /**
129
+ * Extracts the variable name from a command path segment by removing enclosing square brackets.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * getDynamicPathSegmentName("[user]"); // "user"
134
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
135
+ * getDynamicPathSegmentName("[...user]"); // "user"
136
+ * ```
137
+ *
52
138
  * @param path - The command path segment.
53
139
  * @returns The variable name without square brackets.
54
140
  */
55
- declare function getPositionalCommandOptionName(path: string): string;
141
+ declare function getPathSegmentName(path: string): string;
56
142
  //#endregion
57
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases };
143
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isCatchAllPathSegment, isDynamicPathSegment, isOptionalCatchAllPathSegment, isPathSegmentGroup, sortArgAliases };
58
144
  //# sourceMappingURL=context-helpers.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAUgB,iBAtDA,cAAA,CAuDL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAYA;AAUA;;;;;iBA1EgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAUzC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;iBAYnB,yBAAA;;;;;;;iBAUA,8BAAA"}
1
+ {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAoBA;AAiBA;AAiBA;AAoBA;AAmBA;AAgBA;AAiBgB,iBArLA,UAAA,CAqLkB,OAAA,EArLE,iBAqLF,GArLsB,OAqLtB,CAAA,EAAA,MAAA;;;;;;;iBA3JlB,WAAA,UAAqB,oBAAoB;;;;;;;iBAazC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;;;iBAoBnB,oBAAA;;;;;;;;;;;;;;iBAiBA,6BAAA;;;;;;;;;;;;;;iBAiBA,qBAAA;;;;;;;;;;;;;;iBAoBA,yBAAA;;;;;;;;;;;;;;;;iBAmBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA"}
@@ -35,7 +35,7 @@ function getAppName(context) {
35
35
  * @returns The application title in title-case format.
36
36
  */
37
37
  function getAppTitle(context) {
38
- return titleCase(context.config.name || getAppName(context));
38
+ return context.config.title || titleCase(context.config.name || getAppName(context));
39
39
  }
40
40
  /**
41
41
  * Retrieves the application description from the context and configuration.
@@ -58,22 +58,118 @@ function getAppBin(context) {
58
58
  /**
59
59
  * Determines if a given command path segment is variable (enclosed in square brackets).
60
60
  *
61
+ * @example
62
+ * ```typescript
63
+ * isDynamicPathSegment("[user]"); // true
64
+ * isDynamicPathSegment("user"); // false
65
+ * isDynamicPathSegment("[[...user]]"); // true
66
+ * isDynamicPathSegment("[...user]"); // true
67
+ * ```
68
+ *
61
69
  * @param path - The command path segment to check.
62
70
  * @returns True if the path is variable, false otherwise.
63
71
  */
64
- function isPositionalCommandOption(path) {
72
+ function isDynamicPathSegment(path) {
65
73
  return path.startsWith("[") && path.endsWith("]");
66
74
  }
67
75
  /**
76
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * isOptionalCatchAllPathSegment("[[...user]]"); // true
81
+ * isOptionalCatchAllPathSegment("[...user]"); // false
82
+ * isOptionalCatchAllPathSegment("[user]"); // false
83
+ * ```
84
+ *
85
+ * @param path - The command path segment to check.
86
+ * @returns True if the path is an optional catch-all segment, false otherwise.
87
+ */
88
+ function isOptionalCatchAllPathSegment(path) {
89
+ return path.startsWith("[[...") && path.endsWith("]]");
90
+ }
91
+ /**
92
+ * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * isCatchAllPathSegment("[[...user]]"); // true
97
+ * isCatchAllPathSegment("[...user]"); // true
98
+ * isCatchAllPathSegment("[user]"); // false
99
+ * ```
100
+ *
101
+ * @param path - The command path segment to check.
102
+ * @returns True if the path is a catch-all segment, false otherwise.
103
+ */
104
+ function isCatchAllPathSegment(path) {
105
+ return path.startsWith("[...") && path.endsWith("]") || isOptionalCatchAllPathSegment(path);
106
+ }
107
+ /**
68
108
  * Extracts the variable name from a command path segment by removing enclosing square brackets.
69
109
  *
110
+ * @example
111
+ * ```typescript
112
+ * getDynamicPathSegmentName("[user]"); // "user"
113
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
114
+ * getDynamicPathSegmentName("[...user]"); // "user"
115
+ * ```
116
+ *
70
117
  * @param path - The command path segment.
71
118
  * @returns The variable name without square brackets.
72
119
  */
73
- function getPositionalCommandOptionName(path) {
120
+ function getDynamicPathSegmentName(path) {
74
121
  return path.replaceAll(/^\[+(?:\.\.\.)*/g, "").replaceAll(/\]+$/g, "");
75
122
  }
123
+ /**
124
+ * Determines if a given command path segment is a path segment group (enclosed in parentheses).
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * isPathSegmentGroup("(user)"); // true
129
+ * isPathSegmentGroup("[[...user]]"); // false
130
+ * isPathSegmentGroup("[...user]"); // false
131
+ * isPathSegmentGroup("[user]"); // false
132
+ * isPathSegmentGroup("user"); // false
133
+ * ```
134
+ *
135
+ * @param path - The command path segment to check.
136
+ * @returns True if the path is a path segment group, false otherwise.
137
+ */
138
+ function isPathSegmentGroup(path) {
139
+ return path.startsWith("(") && path.endsWith(")");
140
+ }
141
+ /**
142
+ * Extracts the group name from a command path segment by removing enclosing parentheses.
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * getPathSegmentGroupName("(admin)"); // "admin"
147
+ * getPathSegmentGroupName("((group))"); // "group"
148
+ * ```
149
+ *
150
+ * @param path - The command path segment.
151
+ * @returns The group name without parentheses.
152
+ */
153
+ function getPathSegmentGroupName(path) {
154
+ return path.replaceAll(/^\(+/g, "").replaceAll(/\)+$/g, "");
155
+ }
156
+ /**
157
+ * Extracts the variable name from a command path segment by removing enclosing square brackets.
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * getDynamicPathSegmentName("[user]"); // "user"
162
+ * getDynamicPathSegmentName("[[...user]]"); // "user"
163
+ * getDynamicPathSegmentName("[...user]"); // "user"
164
+ * ```
165
+ *
166
+ * @param path - The command path segment.
167
+ * @returns The variable name without square brackets.
168
+ */
169
+ function getPathSegmentName(path) {
170
+ return getPathSegmentGroupName(getDynamicPathSegmentName(path));
171
+ }
76
172
 
77
173
  //#endregion
78
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases };
174
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isCatchAllPathSegment, isDynamicPathSegment, isOptionalCatchAllPathSegment, isPathSegmentGroup, sortArgAliases };
79
175
  //# sourceMappingURL=context-helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","getAppDescription","description","getAppBin","Object","keys","isPositionalCommandOption","path","startsWith","endsWith","getPositionalCommandOptionName","replaceAll"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return titleCase(context.config.name || getAppName(context));\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isPositionalCommandOption(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPositionalCommandOptionName(path: string): string {\n return path.replaceAll(/^\\[+(?:\\.\\.\\.)*/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QAAOf,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAS9D,SAAgBS,kBACdT,SACQ;AACR,QACEA,QAAQC,OAAOS,eACfV,QAAQM,aAAaI,eACrB,OAAOF,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBW,UAAUX,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCS,OAAOC,KAAKb,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;AASpC,SAAgBc,0BAA0BC,MAAuB;AAC/D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;AASnD,SAAgBC,+BAA+BH,MAAsB;AACnE,QAAOA,KAAKI,WAAW,oBAAoB,GAAG,CAACA,WAAW,SAAS,GAAG"}
1
+ {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","title","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","isOptionalCatchAllPathSegment","isCatchAllPathSegment","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return (\n context.config.title ||\n titleCase(context.config.name || getAppName(context))\n );\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * isDynamicPathSegment(\"[[...user]]\"); // true\n * isDynamicPathSegment(\"[...user]\"); // true\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).\n *\n * @example\n * ```typescript\n * isOptionalCatchAllPathSegment(\"[[...user]]\"); // true\n * isOptionalCatchAllPathSegment(\"[...user]\"); // false\n * isOptionalCatchAllPathSegment(\"[user]\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is an optional catch-all segment, false otherwise.\n */\nexport function isOptionalCatchAllPathSegment(path: string): boolean {\n return path.startsWith(\"[[...\") && path.endsWith(\"]]\");\n}\n\n/**\n * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).\n *\n * @example\n * ```typescript\n * isCatchAllPathSegment(\"[[...user]]\"); // true\n * isCatchAllPathSegment(\"[...user]\"); // true\n * isCatchAllPathSegment(\"[user]\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a catch-all segment, false otherwise.\n */\nexport function isCatchAllPathSegment(path: string): boolean {\n return (\n (path.startsWith(\"[...\") && path.endsWith(\"]\")) ||\n isOptionalCatchAllPathSegment(path)\n );\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * getDynamicPathSegmentName(\"[[...user]]\"); // \"user\"\n * getDynamicPathSegmentName(\"[...user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+(?:\\.\\.\\.)*/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[[...user]]\"); // false\n * isPathSegmentGroup(\"[...user]\"); // false\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return path.startsWith(\"(\") && path.endsWith(\")\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path.replaceAll(/^\\(+/g, \"\").replaceAll(/\\)+$/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * getDynamicPathSegmentName(\"[[...user]]\"); // \"user\"\n * getDynamicPathSegmentName(\"[...user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QACEA,QAAQC,OAAOQ,SACfxB,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAUzD,SAAgBU,kBACdV,SACQ;AACR,QACEA,QAAQC,OAAOU,eACfX,QAAQM,aAAaK,eACrB,OAAOH,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBY,UAAUZ,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCU,OAAOC,KAAKd,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;;;AAiBpC,SAAgBe,qBAAqBC,MAAuB;AAC1D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;;;AAgBnD,SAAgBC,8BAA8BH,MAAuB;AACnE,QAAOA,KAAKC,WAAW,QAAQ,IAAID,KAAKE,SAAS,KAAK;;;;;;;;;;;;;;;AAgBxD,SAAgBE,sBAAsBJ,MAAuB;AAC3D,QACGA,KAAKC,WAAW,OAAO,IAAID,KAAKE,SAAS,IAAI,IAC9CC,8BAA8BH,KAAK;;;;;;;;;;;;;;;AAiBvC,SAAgBK,0BAA0BL,MAAsB;AAC9D,QAAOA,KAAKM,WAAW,oBAAoB,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;;;AAkBxE,SAAgBC,mBAAmBP,MAAuB;AACxD,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;;AAenD,SAAgBM,wBAAwBR,MAAsB;AAC5D,QAAOA,KAAKM,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBG,mBAAmBT,MAAsB;AACvD,QAAOQ,wBAAwBH,0BAA0BL,KAAK,CAAC"}
@@ -12,7 +12,7 @@ function getCommandTree(context, path = []) {
12
12
  if (path.length === 0) return null;
13
13
  let currentTree = context.commands[path[0]] ?? null;
14
14
  if (path.length > 1) {
15
- const segments = path.slice(1).filter((segment) => !require_plugin_utils_context_helpers.isPositionalCommandOption(segment));
15
+ const segments = path.slice(1).filter((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment));
16
16
  for (const segment of segments) if (currentTree?.children && Object.prototype.hasOwnProperty.call(currentTree.children, segment)) currentTree = currentTree.children[segment] ?? null;
17
17
  else return null;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-command-tree.cjs","names":["isPositionalCommandOption","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isPositionalCommandOption } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isPositionalCommandOption(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,+DAA0BU,QAAQ,CAAC;AACzD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}
1
+ {"version":3,"file":"get-command-tree.cjs","names":["isDynamicPathSegment","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isDynamicPathSegment } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isDynamicPathSegment(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,0DAAqBU,QAAQ,CAAC;AACpD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}
@@ -1,4 +1,4 @@
1
- import { isPositionalCommandOption } from "./context-helpers.mjs";
1
+ import { isDynamicPathSegment } from "./context-helpers.mjs";
2
2
 
3
3
  //#region src/plugin-utils/get-command-tree.ts
4
4
  /**
@@ -12,7 +12,7 @@ function getCommandTree(context, path = []) {
12
12
  if (path.length === 0) return null;
13
13
  let currentTree = context.commands[path[0]] ?? null;
14
14
  if (path.length > 1) {
15
- const segments = path.slice(1).filter((segment) => !isPositionalCommandOption(segment));
15
+ const segments = path.slice(1).filter((segment) => !isDynamicPathSegment(segment));
16
16
  for (const segment of segments) if (currentTree?.children && Object.prototype.hasOwnProperty.call(currentTree.children, segment)) currentTree = currentTree.children[segment] ?? null;
17
17
  else return null;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-command-tree.mjs","names":["isPositionalCommandOption","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isPositionalCommandOption } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isPositionalCommandOption(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,0BAA0BU,QAAQ,CAAC;AACzD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}
1
+ {"version":3,"file":"get-command-tree.mjs","names":["isDynamicPathSegment","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isDynamicPathSegment } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isDynamicPathSegment(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,qBAAqBU,QAAQ,CAAC;AACpD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}