@h3ravel/musket 2.2.5 → 2.2.7
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.
- package/dist/index.cjs +42 -7
- package/dist/index.d.ts +25 -4
- package/dist/index.js +42 -7
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -114,19 +114,54 @@ var SignatureBuilder = class {
|
|
|
114
114
|
});
|
|
115
115
|
return this;
|
|
116
116
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Add an option/flag.
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
117
|
+
/**
|
|
118
|
+
* Add an option/flag.
|
|
119
|
+
*
|
|
120
|
+
* By default an option is a boolean flag. The name accepts an optional short
|
|
121
|
+
* alias inline using the DSL's `short|long` syntax, with or without leading
|
|
122
|
+
* dashes:
|
|
123
|
+
*
|
|
124
|
+
* ```ts
|
|
125
|
+
* sig.option('dev') // --dev
|
|
126
|
+
* sig.option('--dev') // --dev
|
|
127
|
+
* sig.option('--d|dev') // -d, --dev
|
|
128
|
+
* sig.option('d|dev') // -d, --dev
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* A `short` provided in the {@link OptionDefinition} takes precedence over
|
|
132
|
+
* one parsed from the name.
|
|
133
|
+
*
|
|
134
|
+
* @param name
|
|
135
|
+
* @returns
|
|
122
136
|
*/
|
|
123
137
|
option(name, definition = {}) {
|
|
138
|
+
const { long, short } = this.parseOptionName(name);
|
|
124
139
|
this.opts.push({
|
|
125
|
-
|
|
126
|
-
|
|
140
|
+
...definition,
|
|
141
|
+
name: long,
|
|
142
|
+
short: definition.short ?? short
|
|
127
143
|
});
|
|
128
144
|
return this;
|
|
129
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Parse an option name into its long name and optional short alias. Supports
|
|
148
|
+
* the `short|long` DSL syntax (e.g. `--d|dev`), independent of dash prefixes
|
|
149
|
+
* and part ordering. A single-character part is treated as the short alias;
|
|
150
|
+
* a multi-character part is the long name.
|
|
151
|
+
*/
|
|
152
|
+
parseOptionName(raw) {
|
|
153
|
+
const parts = raw.split("|").map((part) => part.replace(/^--?/, "").trim()).filter(Boolean);
|
|
154
|
+
let long;
|
|
155
|
+
let short;
|
|
156
|
+
for (const part of parts) if (part.length === 1 && short === void 0) short = part;
|
|
157
|
+
else long ??= part;
|
|
158
|
+
long ??= short ?? "";
|
|
159
|
+
if (long === short) short = void 0;
|
|
160
|
+
return {
|
|
161
|
+
long,
|
|
162
|
+
short
|
|
163
|
+
};
|
|
164
|
+
}
|
|
130
165
|
/**
|
|
131
166
|
* The configured command name (empty when unset).
|
|
132
167
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -435,11 +435,32 @@ declare class SignatureBuilder {
|
|
|
435
435
|
argument(name: string, definition?: ArgumentDefinition): this;
|
|
436
436
|
/**
|
|
437
437
|
* Add an option/flag.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
438
|
+
*
|
|
439
|
+
* By default an option is a boolean flag. The name accepts an optional short
|
|
440
|
+
* alias inline using the DSL's `short|long` syntax, with or without leading
|
|
441
|
+
* dashes:
|
|
442
|
+
*
|
|
443
|
+
* ```ts
|
|
444
|
+
* sig.option('dev') // --dev
|
|
445
|
+
* sig.option('--dev') // --dev
|
|
446
|
+
* sig.option('--d|dev') // -d, --dev
|
|
447
|
+
* sig.option('d|dev') // -d, --dev
|
|
448
|
+
* ```
|
|
449
|
+
*
|
|
450
|
+
* A `short` provided in the {@link OptionDefinition} takes precedence over
|
|
451
|
+
* one parsed from the name.
|
|
452
|
+
*
|
|
453
|
+
* @param name
|
|
454
|
+
* @returns
|
|
455
|
+
*/
|
|
442
456
|
option(name: string, definition?: OptionDefinition): this;
|
|
457
|
+
/**
|
|
458
|
+
* Parse an option name into its long name and optional short alias. Supports
|
|
459
|
+
* the `short|long` DSL syntax (e.g. `--d|dev`), independent of dash prefixes
|
|
460
|
+
* and part ordering. A single-character part is treated as the short alias;
|
|
461
|
+
* a multi-character part is the long name.
|
|
462
|
+
*/
|
|
463
|
+
private parseOptionName;
|
|
443
464
|
/**
|
|
444
465
|
* The configured command name (empty when unset).
|
|
445
466
|
*
|
package/dist/index.js
CHANGED
|
@@ -90,19 +90,54 @@ var SignatureBuilder = class {
|
|
|
90
90
|
});
|
|
91
91
|
return this;
|
|
92
92
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Add an option/flag.
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
93
|
+
/**
|
|
94
|
+
* Add an option/flag.
|
|
95
|
+
*
|
|
96
|
+
* By default an option is a boolean flag. The name accepts an optional short
|
|
97
|
+
* alias inline using the DSL's `short|long` syntax, with or without leading
|
|
98
|
+
* dashes:
|
|
99
|
+
*
|
|
100
|
+
* ```ts
|
|
101
|
+
* sig.option('dev') // --dev
|
|
102
|
+
* sig.option('--dev') // --dev
|
|
103
|
+
* sig.option('--d|dev') // -d, --dev
|
|
104
|
+
* sig.option('d|dev') // -d, --dev
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* A `short` provided in the {@link OptionDefinition} takes precedence over
|
|
108
|
+
* one parsed from the name.
|
|
109
|
+
*
|
|
110
|
+
* @param name
|
|
111
|
+
* @returns
|
|
98
112
|
*/
|
|
99
113
|
option(name, definition = {}) {
|
|
114
|
+
const { long, short } = this.parseOptionName(name);
|
|
100
115
|
this.opts.push({
|
|
101
|
-
|
|
102
|
-
|
|
116
|
+
...definition,
|
|
117
|
+
name: long,
|
|
118
|
+
short: definition.short ?? short
|
|
103
119
|
});
|
|
104
120
|
return this;
|
|
105
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Parse an option name into its long name and optional short alias. Supports
|
|
124
|
+
* the `short|long` DSL syntax (e.g. `--d|dev`), independent of dash prefixes
|
|
125
|
+
* and part ordering. A single-character part is treated as the short alias;
|
|
126
|
+
* a multi-character part is the long name.
|
|
127
|
+
*/
|
|
128
|
+
parseOptionName(raw) {
|
|
129
|
+
const parts = raw.split("|").map((part) => part.replace(/^--?/, "").trim()).filter(Boolean);
|
|
130
|
+
let long;
|
|
131
|
+
let short;
|
|
132
|
+
for (const part of parts) if (part.length === 1 && short === void 0) short = part;
|
|
133
|
+
else long ??= part;
|
|
134
|
+
long ??= short ?? "";
|
|
135
|
+
if (long === short) short = void 0;
|
|
136
|
+
return {
|
|
137
|
+
long,
|
|
138
|
+
short
|
|
139
|
+
};
|
|
140
|
+
}
|
|
106
141
|
/**
|
|
107
142
|
* The configured command name (empty when unset).
|
|
108
143
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/musket",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"description": "Musket CLI is a framework-agnostic CLI framework designed to allow you build artisan-like CLI apps and for use in the H3ravel framework.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"execa": "^9.6.0",
|
|
74
74
|
"glob": "^13.0.6",
|
|
75
75
|
"preferred-pm": "^4.1.1",
|
|
76
|
-
"radashi": "^12.6.2",
|
|
77
76
|
"resolve-from": "^5.0.0",
|
|
78
77
|
"tsx": "^4.20.5"
|
|
79
78
|
},
|