citty 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  Elegant CLI Builder
12
12
 
13
13
  - Zero dependency
14
- - Fast and lightweight argument parser (based on native [node utils](arg parser](https://nodejs.org/api/util.html#utilparseargsconfig))
14
+ - Fast and lightweight argument parser (based on native [Node.js `util.parseArgs`](https://nodejs.org/api/util.html#utilparseargsconfig))
15
15
  - Smart value parsing with typecast and boolean shortcuts
16
16
  - Nested sub-commands
17
17
  - Lazy and Async commands
@@ -0,0 +1,33 @@
1
+ # Licenses of Bundled Dependencies
2
+
3
+ The published artifact additionally contains code with the following licenses:
4
+ MIT
5
+
6
+ # Bundled Dependencies
7
+
8
+ ## scule
9
+
10
+ License: MIT
11
+ Repository: https://github.com/unjs/scule
12
+
13
+ > MIT License
14
+ >
15
+ > Copyright (c) Pooya Parsa <pooya@pi0.io>
16
+ >
17
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ > of this software and associated documentation files (the "Software"), to deal
19
+ > in the Software without restriction, including without limitation the rights
20
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ > copies of the Software, and to permit persons to whom the Software is
22
+ > furnished to do so, subject to the following conditions:
23
+ >
24
+ > The above copyright notice and this permission notice shall be included in all
25
+ > copies or substantial portions of the Software.
26
+ >
27
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ > SOFTWARE.
@@ -1,4 +1,3 @@
1
- //#region node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
2
1
  const NUMBER_CHAR_RE = /\d/;
3
2
  const STR_SPLITTERS = [
4
3
  "-",
@@ -63,6 +62,4 @@ function camelCase(str, opts) {
63
62
  function kebabCase(str, joiner) {
64
63
  return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
65
64
  }
66
-
67
- //#endregion
68
- export { kebabCase as n, camelCase as t };
65
+ export { kebabCase as n, camelCase as t };
package/dist/index.mjs CHANGED
@@ -1,7 +1,5 @@
1
1
  import { n as kebabCase, t as camelCase } from "./_chunks/libs/scule.mjs";
2
2
  import { parseArgs as parseArgs$1 } from "node:util";
3
-
4
- //#region src/_utils.ts
5
3
  function toArray(val) {
6
4
  if (Array.isArray(val)) return val;
7
5
  return val === void 0 ? [] : [val];
@@ -22,9 +20,6 @@ var CLIError = class extends Error {
22
20
  this.code = code;
23
21
  }
24
22
  };
25
-
26
- //#endregion
27
- //#region src/_parser.ts
28
23
  function parseRawArgs(args = [], opts = {}) {
29
24
  const booleans = new Set(opts.boolean || []);
30
25
  const strings = new Set(opts.string || []);
@@ -94,16 +89,19 @@ function parseRawArgs(args = [], opts = {}) {
94
89
  const out = { _: [] };
95
90
  out._ = parsed.positionals;
96
91
  for (const [key, value] of Object.entries(parsed.values)) out[key] = value;
97
- for (const [name] of Object.entries(negatedFlags)) out[name] = false;
92
+ for (const [name] of Object.entries(negatedFlags)) {
93
+ out[name] = false;
94
+ const mainName = aliasToMain.get(name);
95
+ if (mainName) out[mainName] = false;
96
+ const aliases = mainToAliases.get(name);
97
+ if (aliases) for (const alias of aliases) out[alias] = false;
98
+ }
98
99
  for (const [alias, main] of aliasToMain.entries()) {
99
100
  if (out[alias] !== void 0 && out[main] === void 0) out[main] = out[alias];
100
101
  if (out[main] !== void 0 && out[alias] === void 0) out[alias] = out[main];
101
102
  }
102
103
  return out;
103
104
  }
104
-
105
- //#endregion
106
- //#region src/_color.ts
107
105
  const noColor = /* @__PURE__ */ (() => {
108
106
  const env = globalThis.process?.env ?? {};
109
107
  return env.NO_COLOR === "1" || env.TERM === "dumb" || env.TEST || env.CI;
@@ -113,9 +111,6 @@ const bold = /* @__PURE__ */ _c(1, 22);
113
111
  const cyan = /* @__PURE__ */ _c(36);
114
112
  const gray = /* @__PURE__ */ _c(90);
115
113
  const underline = /* @__PURE__ */ _c(4, 24);
116
-
117
- //#endregion
118
- //#region src/args.ts
119
114
  function parseArgs(rawArgs, argsDef) {
120
115
  const parseOptions = {
121
116
  boolean: [],
@@ -165,9 +160,6 @@ function resolveArgs(argsDef) {
165
160
  });
166
161
  return args;
167
162
  }
168
-
169
- //#endregion
170
- //#region src/command.ts
171
163
  function defineCommand(def) {
172
164
  return def;
173
165
  }
@@ -209,9 +201,6 @@ async function resolveSubCommand(cmd, rawArgs, parent) {
209
201
  }
210
202
  return [cmd, parent];
211
203
  }
212
-
213
- //#endregion
214
- //#region src/usage.ts
215
204
  async function showUsage(cmd, parent) {
216
205
  try {
217
206
  console.log(await renderUsage(cmd, parent) + "\n");
@@ -243,11 +232,6 @@ async function renderUsage(cmd, parent) {
243
232
  const isRequired = arg.required === true && arg.default === void 0;
244
233
  const argStr = [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ") + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "") + (arg.type === "enum" && arg.options ? `=<${arg.options.join("|")}>` : "");
245
234
  argLines.push([cyan(argStr + (isRequired ? " (required)" : "")), arg.description || ""]);
246
- /**
247
- * print negative boolean arg variant usage when
248
- * - enabled by default or has `negativeDescription`
249
- * - not prefixed with `no-` or `no[A-Z]`
250
- */
251
235
  if (arg.type === "boolean" && (arg.default === true || arg.negativeDescription) && !negativePrefixRe.test(arg.name)) {
252
236
  const negativeArgStr = [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ");
253
237
  argLines.push([cyan(negativeArgStr + (isRequired ? " (required)" : "")), arg.negativeDescription || ""]);
@@ -287,9 +271,6 @@ async function renderUsage(cmd, parent) {
287
271
  }
288
272
  return usageLines.filter((l) => typeof l === "string").join("\n");
289
273
  }
290
-
291
- //#endregion
292
- //#region src/main.ts
293
274
  async function runMain(cmd, opts = {}) {
294
275
  const rawArgs = opts.rawArgs || process.argv.slice(2);
295
276
  const showUsage$1 = opts.showUsage || showUsage;
@@ -313,6 +294,4 @@ async function runMain(cmd, opts = {}) {
313
294
  function createMain(cmd) {
314
295
  return (opts = {}) => runMain(cmd, opts);
315
296
  }
316
-
317
- //#endregion
318
- export { createMain, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage };
297
+ export { createMain, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage };
package/package.json CHANGED
@@ -1,41 +1,42 @@
1
1
  {
2
2
  "name": "citty",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Elegant CLI Builder",
5
- "repository": "unjs/citty",
6
5
  "license": "MIT",
7
- "sideEffects": false,
6
+ "repository": "unjs/citty",
7
+ "files": [
8
+ "dist"
9
+ ],
8
10
  "type": "module",
11
+ "sideEffects": false,
12
+ "types": "./dist/index.d.mts",
9
13
  "exports": {
10
14
  ".": "./dist/index.mjs"
11
15
  },
12
- "types": "./dist/index.d.mts",
13
- "files": [
14
- "dist"
15
- ],
16
16
  "scripts": {
17
17
  "build": "obuild",
18
18
  "dev": "vitest dev",
19
- "lint": "eslint --cache . && prettier -c src test",
20
- "lint:fix": "eslint --cache . --fix && prettier -c src test -w",
19
+ "lint": "oxlint . && oxfmt --check",
20
+ "lint:fix": "oxlint . --fix && oxfmt",
21
21
  "prepack": "pnpm run build",
22
22
  "play": "node ./playground/cli.ts",
23
23
  "release": "pnpm test && pnpm build && changelogen --release --push && npm publish",
24
24
  "test": "pnpm lint && pnpm test:types && vitest run --coverage",
25
- "test:types": "tsc --noEmit"
25
+ "test:types": "tsgo --noEmit"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/node": "^25.0.9",
29
- "@vitest/coverage-v8": "^4.0.17",
30
- "automd": "^0.4.2",
28
+ "@types/node": "^25.2.3",
29
+ "@typescript/native-preview": "7.0.0-dev.20260212.1",
30
+ "@vitest/coverage-v8": "^4.0.18",
31
+ "automd": "^0.4.3",
31
32
  "changelogen": "^0.6.2",
32
- "eslint": "^9.39.2",
33
33
  "eslint-config-unjs": "^0.6.2",
34
- "obuild": "^0.4.18",
35
- "prettier": "^3.8.0",
34
+ "obuild": "^0.4.27",
35
+ "oxfmt": "^0.32.0",
36
+ "oxlint": "^1.47.0",
36
37
  "scule": "^1.3.0",
37
38
  "typescript": "^5.9.3",
38
- "vitest": "^4.0.17"
39
+ "vitest": "^4.0.18"
39
40
  },
40
- "packageManager": "pnpm@10.28.1"
41
+ "packageManager": "pnpm@10.29.3"
41
42
  }