politty 0.11.0 → 0.11.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/LICENSE +21 -0
- package/README.md +1 -2
- package/dist/cli.js +2 -2
- package/dist/completion/index.js +1 -1
- package/dist/{completion-CqKX9sCR.js → completion-Rx2DiNBn.js} +3 -3
- package/dist/docs/index.js +2 -2
- package/dist/index.js +3 -3
- package/dist/{runner-Z7R_XvAV.js → runner-DpsAMVta.js} +33 -7
- package/dist/{schema-extractor-DnOTAjV_.js → schema-extractor-GEuI_L0X.js} +2 -2
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 toiroakr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ From simple scripts to complex CLI tools with subcommands, validation, and auto-
|
|
|
19
19
|
|
|
20
20
|
## Requirements
|
|
21
21
|
|
|
22
|
-
- Node.js >=
|
|
22
|
+
- Node.js >= 20.12.0 (excluding 21.0.0 - 21.6.x)
|
|
23
23
|
- Zod >= 4.2.1
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
@@ -264,7 +264,6 @@ CLI entry point. Handles signals and calls `process.exit()`.
|
|
|
264
264
|
```typescript
|
|
265
265
|
runMain(command, {
|
|
266
266
|
version: "1.0.0", // Displayed with --version flag
|
|
267
|
-
argv: process.argv, // Custom argv
|
|
268
267
|
});
|
|
269
268
|
```
|
|
270
269
|
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as runMain } from "./runner-
|
|
2
|
+
import { n as runMain } from "./runner-DpsAMVta.js";
|
|
3
3
|
import { t as arg } from "./arg-registry-BeLLAW5-.js";
|
|
4
4
|
import { n as defineCommand } from "./command-B4yA4LXX.js";
|
|
5
|
-
import { p as generateBundledCompletionWorker } from "./completion-
|
|
5
|
+
import { p as generateBundledCompletionWorker } from "./completion-Rx2DiNBn.js";
|
|
6
6
|
import "./index.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
package/dist/completion/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as CompletionDirective, a as generateCompletion, b as resolveValueCompletion, c as createDynamicCompleteCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as extractPositionals, h as extractCompletionData, i as detectShell, l as hasCompleteCommand, m as validateBundledWorkerFile, n as createCompletionWorkerPathCommand, o as getSupportedShells, p as generateBundledCompletionWorker, r as createRefreshCompletionCommand, s as withCompletionCommand, t as createCompletionCommand, u as formatForShell, v as generateCandidates, y as parseCompletionContext } from "../completion-
|
|
1
|
+
import { _ as CompletionDirective, a as generateCompletion, b as resolveValueCompletion, c as createDynamicCompleteCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as extractPositionals, h as extractCompletionData, i as detectShell, l as hasCompleteCommand, m as validateBundledWorkerFile, n as createCompletionWorkerPathCommand, o as getSupportedShells, p as generateBundledCompletionWorker, r as createRefreshCompletionCommand, s as withCompletionCommand, t as createCompletionCommand, u as formatForShell, v as generateCandidates, y as parseCompletionContext } from "../completion-Rx2DiNBn.js";
|
|
2
2
|
|
|
3
3
|
export { CompletionDirective, bundledWorkerShellExtension, createCompletionCommand, createCompletionWorkerPathCommand, createDynamicCompleteCommand, createRefreshCompletionCommand, defaultBundledWorkerOutputPath, detectShell, extractCompletionData, extractPositionals, formatForShell, generateBundledCompletionWorker, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, validateBundledWorkerFile, withCompletionCommand };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as arg } from "./arg-registry-BeLLAW5-.js";
|
|
2
2
|
import { n as defineCommand } from "./command-B4yA4LXX.js";
|
|
3
|
-
import { a as toCamelCase, m as resolveSubCommandMeta, n as getAllAliases, t as extractFields, u as resolveSubCommandAlias } from "./schema-extractor-
|
|
3
|
+
import { a as toCamelCase, m as resolveSubCommandMeta, n as getAllAliases, t as extractFields, u as resolveSubCommandAlias } from "./schema-extractor-GEuI_L0X.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { execFile, execSync, spawn } from "node:child_process";
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -476,7 +476,7 @@ function getSubcommandNames(command) {
|
|
|
476
476
|
*/
|
|
477
477
|
function resolveSubcommand(command, name) {
|
|
478
478
|
if (!command.subCommands) return null;
|
|
479
|
-
const sub = command.subCommands[name];
|
|
479
|
+
const sub = Object.hasOwn(command.subCommands, name) ? command.subCommands[name] : void 0;
|
|
480
480
|
if (sub) return resolveSubCommandMeta(sub);
|
|
481
481
|
const canonical = resolveSubCommandAlias(command, name);
|
|
482
482
|
if (canonical) return resolveSubCommandMeta(command.subCommands[canonical]);
|
|
@@ -5606,4 +5606,4 @@ function maybeSpawnRefresh(argv, ctx) {
|
|
|
5606
5606
|
|
|
5607
5607
|
//#endregion
|
|
5608
5608
|
export { CompletionDirective as _, generateCompletion as a, resolveValueCompletion as b, createDynamicCompleteCommand as c, bundledWorkerShellExtension as d, defaultBundledWorkerOutputPath as f, extractPositionals as g, extractCompletionData as h, detectShell as i, hasCompleteCommand as l, validateBundledWorkerFile as m, createCompletionWorkerPathCommand as n, getSupportedShells as o, generateBundledCompletionWorker as p, createRefreshCompletionCommand as r, withCompletionCommand as s, createCompletionCommand as t, formatForShell as u, generateCandidates as v, parseCompletionContext as y };
|
|
5609
|
-
//# sourceMappingURL=completion-
|
|
5609
|
+
//# sourceMappingURL=completion-Rx2DiNBn.js.map
|
package/dist/docs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as resolveLazyCommand, r as getExtractedFields, t as extractFields } from "../schema-extractor-
|
|
1
|
+
import { l as resolveLazyCommand, r as getExtractedFields, t as extractFields } from "../schema-extractor-GEuI_L0X.js";
|
|
2
2
|
import { t as createLogCollector } from "../log-collector-DK32-73m.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import * as fs from "node:fs";
|
|
@@ -919,7 +919,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
|
|
|
919
919
|
collector.start();
|
|
920
920
|
let success = true;
|
|
921
921
|
try {
|
|
922
|
-
const { runCommand } = await import("../runner-
|
|
922
|
+
const { runCommand } = await import("../runner-DpsAMVta.js").then((n) => n.r);
|
|
923
923
|
const result = await runCommand(rootCommand, argv);
|
|
924
924
|
success = result.success;
|
|
925
925
|
if (!result.success && result.error) console.error(result.error.message);
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as renderMarkdown, S as renderInline, _ as DuplicateFieldError, a as parseArgv, b as ReservedAliasError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as DuplicateAliasError, h as CaseVariantCollisionError, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateNegationError, w as createDualCaseProxy, x as generateHelp, y as PositionalConfigError } from "./runner-
|
|
1
|
+
import { C as renderMarkdown, S as renderInline, _ as DuplicateFieldError, a as parseArgv, b as ReservedAliasError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as DuplicateAliasError, h as CaseVariantCollisionError, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateNegationError, w as createDualCaseProxy, x as generateHelp, y as PositionalConfigError } from "./runner-DpsAMVta.js";
|
|
2
2
|
import { t as arg } from "./arg-registry-BeLLAW5-.js";
|
|
3
3
|
import { n as defineCommand, t as createDefineCommand } from "./command-B4yA4LXX.js";
|
|
4
|
-
import { a as toCamelCase, f as isLazyCommand, i as getUnknownKeysMode, o as toKebabCase, p as lazy, t as extractFields } from "./schema-extractor-
|
|
5
|
-
import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-
|
|
4
|
+
import { a as toCamelCase, f as isLazyCommand, i as getUnknownKeysMode, o as toKebabCase, p as lazy, t as extractFields } from "./schema-extractor-GEuI_L0X.js";
|
|
5
|
+
import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-Rx2DiNBn.js";
|
|
6
6
|
import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-DbDkjdfO.js";
|
|
7
7
|
|
|
8
8
|
export { CaseVariantCollisionError, DuplicateAliasError, DuplicateFieldError, DuplicateNegationError, PositionalConfigError, ReservedAliasError, arg, createDefineCommand, createDualCaseProxy, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateBundledCompletionWorker, generateCompletion, generateHelp, getUnknownKeysMode, isColorEnabled, isLazyCommand, lazy, logger, parseArgv, renderInline, renderMarkdown, runCommand, runMain, setColorEnabled, styles, symbols, toCamelCase, toKebabCase, validateCaseVariantCollisions, validateCommand, validateCrossSchemaCollisions, validateDuplicateAliases, validateDuplicateFields, validateDuplicateNegations, validatePositionalConfig, validateReservedAliases, withCompletionCommand };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as toCamelCase, c as listSubCommands, d as resolveSubcommandWithAlias, f as isLazyCommand, l as resolveLazyCommand, m as resolveSubCommandMeta, n as getAllAliases, o as toKebabCase, r as getExtractedFields, s as listSubCommandNamesWithAliases, t as extractFields } from "./schema-extractor-
|
|
1
|
+
import { a as toCamelCase, c as listSubCommands, d as resolveSubcommandWithAlias, f as isLazyCommand, l as resolveLazyCommand, m as resolveSubCommandMeta, n as getAllAliases, o as toKebabCase, r as getExtractedFields, s as listSubCommandNamesWithAliases, t as extractFields } from "./schema-extractor-GEuI_L0X.js";
|
|
2
2
|
import { n as emptyLogs, r as mergeLogs, t as createLogCollector } from "./log-collector-DK32-73m.js";
|
|
3
3
|
import { a as symbols, i as styles } from "./logger-DbDkjdfO.js";
|
|
4
4
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -1496,6 +1496,26 @@ function resolveLongOption(arg, lookup) {
|
|
|
1496
1496
|
//#endregion
|
|
1497
1497
|
//#region src/parser/argv-parser.ts
|
|
1498
1498
|
/**
|
|
1499
|
+
* Coerce a `--flag=value` string to a boolean for boolean-typed flags.
|
|
1500
|
+
* Values other than "true"/"false" are passed through unchanged so
|
|
1501
|
+
* downstream validation reports the invalid input instead of silently
|
|
1502
|
+
* guessing.
|
|
1503
|
+
*/
|
|
1504
|
+
function coerceBoolean(value) {
|
|
1505
|
+
if (value === "true") return true;
|
|
1506
|
+
if (value === "false") return false;
|
|
1507
|
+
return value;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Matches tokens that look like a negative number (e.g. "-5", "-5.2", "-.5"),
|
|
1511
|
+
* as opposed to another flag. Used to decide whether a dash-prefixed token
|
|
1512
|
+
* should still be consumed as a value-taking option's value.
|
|
1513
|
+
*/
|
|
1514
|
+
const NEGATIVE_NUMBER_PATTERN = /^-\.?\d/;
|
|
1515
|
+
function looksLikeNegativeNumber(value) {
|
|
1516
|
+
return NEGATIVE_NUMBER_PATTERN.test(value);
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1499
1519
|
* Parse argv into a flat record
|
|
1500
1520
|
*
|
|
1501
1521
|
* Supports:
|
|
@@ -1568,7 +1588,10 @@ function parseArgv(argv, options = {}) {
|
|
|
1568
1588
|
}
|
|
1569
1589
|
const eqIndex = withoutDashes.indexOf("=");
|
|
1570
1590
|
if (eqIndex !== -1) {
|
|
1571
|
-
|
|
1591
|
+
const name = withoutDashes.slice(0, eqIndex);
|
|
1592
|
+
const value = withoutDashes.slice(eqIndex + 1);
|
|
1593
|
+
const resolvedName = aliasMap.get(name) ?? name;
|
|
1594
|
+
setOption(name, booleanFlags.has(resolvedName) ? coerceBoolean(value) : value);
|
|
1572
1595
|
i++;
|
|
1573
1596
|
} else {
|
|
1574
1597
|
const name = withoutDashes;
|
|
@@ -1578,7 +1601,7 @@ function parseArgv(argv, options = {}) {
|
|
|
1578
1601
|
i++;
|
|
1579
1602
|
} else {
|
|
1580
1603
|
const nextArg = argv[i + 1];
|
|
1581
|
-
if (nextArg !== void 0 && !nextArg.startsWith("-")) {
|
|
1604
|
+
if (nextArg !== void 0 && (!nextArg.startsWith("-") || looksLikeNegativeNumber(nextArg))) {
|
|
1582
1605
|
setOption(name, nextArg);
|
|
1583
1606
|
i += 2;
|
|
1584
1607
|
} else {
|
|
@@ -1593,7 +1616,10 @@ function parseArgv(argv, options = {}) {
|
|
|
1593
1616
|
const withoutDash = arg.slice(1);
|
|
1594
1617
|
const eqIndex = withoutDash.indexOf("=");
|
|
1595
1618
|
if (eqIndex !== -1) {
|
|
1596
|
-
|
|
1619
|
+
const name = withoutDash.slice(0, eqIndex);
|
|
1620
|
+
const value = withoutDash.slice(eqIndex + 1);
|
|
1621
|
+
const resolvedName = aliasMap.get(name) ?? name;
|
|
1622
|
+
setOption(name, booleanFlags.has(resolvedName) ? coerceBoolean(value) : value);
|
|
1597
1623
|
i++;
|
|
1598
1624
|
} else if (withoutDash.length === 1) {
|
|
1599
1625
|
const name = withoutDash;
|
|
@@ -1603,7 +1629,7 @@ function parseArgv(argv, options = {}) {
|
|
|
1603
1629
|
i++;
|
|
1604
1630
|
} else {
|
|
1605
1631
|
const nextArg = argv[i + 1];
|
|
1606
|
-
if (nextArg !== void 0 && !nextArg.startsWith("-")) {
|
|
1632
|
+
if (nextArg !== void 0 && (!nextArg.startsWith("-") || looksLikeNegativeNumber(nextArg))) {
|
|
1607
1633
|
setOption(name, nextArg);
|
|
1608
1634
|
i += 2;
|
|
1609
1635
|
} else {
|
|
@@ -2342,7 +2368,7 @@ async function runCommand(command, argv, options = {}) {
|
|
|
2342
2368
|
function isInternalSubcommandInvocation(command, argv, globalExtracted) {
|
|
2343
2369
|
const firstPositional = findFirstPositional(argv, globalExtracted);
|
|
2344
2370
|
if (!firstPositional || !firstPositional.startsWith("__")) return false;
|
|
2345
|
-
return
|
|
2371
|
+
return Object.hasOwn(command.subCommands ?? {}, firstPositional);
|
|
2346
2372
|
}
|
|
2347
2373
|
/**
|
|
2348
2374
|
* Run a CLI command as the main entry point
|
|
@@ -2760,4 +2786,4 @@ function extractAndValidateGlobal(options) {
|
|
|
2760
2786
|
|
|
2761
2787
|
//#endregion
|
|
2762
2788
|
export { renderMarkdown as C, renderInline as S, DuplicateFieldError as _, parseArgv as a, ReservedAliasError as b, validateCommand as c, validateDuplicateFields as d, validateDuplicateNegations as f, DuplicateAliasError as g, CaseVariantCollisionError as h, formatValidationErrors as i, validateCrossSchemaCollisions as l, validateReservedAliases as m, runMain as n, formatCommandValidationErrors as o, validatePositionalConfig as p, runner_exports as r, validateCaseVariantCollisions as s, runCommand as t, validateDuplicateAliases as u, DuplicateNegationError as v, createDualCaseProxy as w, generateHelp as x, PositionalConfigError as y };
|
|
2763
|
-
//# sourceMappingURL=runner-
|
|
2789
|
+
//# sourceMappingURL=runner-DpsAMVta.js.map
|
|
@@ -77,7 +77,7 @@ async function resolveLazyCommand(cmd) {
|
|
|
77
77
|
*/
|
|
78
78
|
async function resolveSubcommandWithAlias(command, name) {
|
|
79
79
|
if (!command.subCommands) return;
|
|
80
|
-
const subCmd = command.subCommands[name];
|
|
80
|
+
const subCmd = Object.hasOwn(command.subCommands, name) ? command.subCommands[name] : void 0;
|
|
81
81
|
if (subCmd) return {
|
|
82
82
|
command: await resolveLazyCommand(subCmd),
|
|
83
83
|
aliasFor: void 0
|
|
@@ -597,4 +597,4 @@ function getExtractedFields(command) {
|
|
|
597
597
|
|
|
598
598
|
//#endregion
|
|
599
599
|
export { toCamelCase as a, listSubCommands as c, resolveSubcommandWithAlias as d, isLazyCommand as f, getUnknownKeysMode as i, resolveLazyCommand as l, resolveSubCommandMeta as m, getAllAliases as n, toKebabCase as o, lazy as p, getExtractedFields as r, listSubCommandNamesWithAliases as s, extractFields as t, resolveSubCommandAlias as u };
|
|
600
|
-
//# sourceMappingURL=schema-extractor-
|
|
600
|
+
//# sourceMappingURL=schema-extractor-GEuI_L0X.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "politty",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "A lightweight CLI framework inspired by citty with zod v4 registry integration for type-safe metadata management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"argument-parser",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"zod"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"author": "",
|
|
14
|
+
"author": "toiroakr",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "https://github.com/toiroakr/politty.git"
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"@inquirer/prompts": "8.5.2",
|
|
70
70
|
"@quansync/fs": "1.0.0",
|
|
71
71
|
"@types/node": "25.9.4",
|
|
72
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
72
|
+
"@typescript/native-preview": "7.0.0-dev.20260701.1",
|
|
73
73
|
"@vitest/coverage-v8": "4.1.9",
|
|
74
|
-
"knip": "6.
|
|
74
|
+
"knip": "6.23.0",
|
|
75
75
|
"lefthook": "2.1.9",
|
|
76
76
|
"organize-imports-cli": "1.0.2",
|
|
77
|
-
"oxfmt": "0.
|
|
78
|
-
"oxlint": "1.
|
|
77
|
+
"oxfmt": "0.57.0",
|
|
78
|
+
"oxlint": "1.72.0",
|
|
79
79
|
"quansync": "1.0.0",
|
|
80
80
|
"tsdown": "0.22.3",
|
|
81
81
|
"tsx": "4.22.4",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"engines": {
|
|
100
|
-
"node": ">=
|
|
100
|
+
"node": ">=20.12.0 <21.0.0 || >=21.7.0"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"build": "tsdown",
|