politty 0.0.1 → 0.1.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.
Files changed (56) hide show
  1. package/README.md +297 -28
  2. package/dist/arg-registry-ClI2WGgH.d.cts +89 -0
  3. package/dist/arg-registry-ClI2WGgH.d.cts.map +1 -0
  4. package/dist/arg-registry-D4NsqcNZ.d.ts +89 -0
  5. package/dist/arg-registry-D4NsqcNZ.d.ts.map +1 -0
  6. package/dist/augment.cjs +0 -0
  7. package/dist/augment.d.cts +17 -0
  8. package/dist/augment.d.cts.map +1 -0
  9. package/dist/augment.d.ts +17 -0
  10. package/dist/augment.d.ts.map +1 -0
  11. package/dist/augment.js +1 -0
  12. package/dist/command-Bgd-yIwv.cjs +25 -0
  13. package/dist/command-Bgd-yIwv.cjs.map +1 -0
  14. package/dist/command-CvKyk4ag.js +20 -0
  15. package/dist/command-CvKyk4ag.js.map +1 -0
  16. package/dist/completion/index.cjs +595 -0
  17. package/dist/completion/index.cjs.map +1 -0
  18. package/dist/completion/index.d.cts +153 -0
  19. package/dist/completion/index.d.cts.map +1 -0
  20. package/dist/completion/index.d.ts +153 -0
  21. package/dist/completion/index.d.ts.map +1 -0
  22. package/dist/completion/index.js +588 -0
  23. package/dist/completion/index.js.map +1 -0
  24. package/dist/docs/index.cjs +1239 -0
  25. package/dist/docs/index.cjs.map +1 -0
  26. package/dist/docs/index.d.cts +500 -0
  27. package/dist/docs/index.d.cts.map +1 -0
  28. package/dist/docs/index.d.ts +500 -0
  29. package/dist/docs/index.d.ts.map +1 -0
  30. package/dist/docs/index.js +1182 -0
  31. package/dist/docs/index.js.map +1 -0
  32. package/dist/index.cjs +29 -0
  33. package/dist/index.d.cts +478 -0
  34. package/dist/index.d.cts.map +1 -0
  35. package/dist/index.d.ts +478 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +5 -0
  38. package/dist/runner-BZuYiRhi.cjs +1492 -0
  39. package/dist/runner-BZuYiRhi.cjs.map +1 -0
  40. package/dist/runner-D2BXiWtg.cjs +4 -0
  41. package/dist/runner-DceWXOwD.js +1372 -0
  42. package/dist/runner-DceWXOwD.js.map +1 -0
  43. package/dist/runner-KCql2UKz.js +4 -0
  44. package/dist/schema-extractor-B9D3Rf22.cjs +354 -0
  45. package/dist/schema-extractor-B9D3Rf22.cjs.map +1 -0
  46. package/dist/schema-extractor-D-Eo7I77.d.cts +303 -0
  47. package/dist/schema-extractor-D-Eo7I77.d.cts.map +1 -0
  48. package/dist/schema-extractor-Dk5Z0Iei.js +324 -0
  49. package/dist/schema-extractor-Dk5Z0Iei.js.map +1 -0
  50. package/dist/schema-extractor-kkajLb9E.d.ts +303 -0
  51. package/dist/schema-extractor-kkajLb9E.d.ts.map +1 -0
  52. package/dist/subcommand-router-BiSvDXHg.js +153 -0
  53. package/dist/subcommand-router-BiSvDXHg.js.map +1 -0
  54. package/dist/subcommand-router-Vf-0w9P4.cjs +189 -0
  55. package/dist/subcommand-router-Vf-0w9P4.cjs.map +1 -0
  56. package/package.json +108 -6
@@ -0,0 +1,153 @@
1
+ import { d as Command, n as ResolvedFieldMeta, s as AnyCommand } from "../schema-extractor-D-Eo7I77.cjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/completion/types.d.ts
5
+
6
+ /**
7
+ * Supported shell types for completion
8
+ */
9
+ type ShellType = "bash" | "zsh" | "fish";
10
+ /**
11
+ * Options for completion generation
12
+ */
13
+ interface CompletionOptions {
14
+ /** The shell type to generate completion for */
15
+ shell: ShellType;
16
+ /** The command name as it will be invoked */
17
+ programName: string;
18
+ /** Include subcommand completions (default: true) */
19
+ includeSubcommands?: boolean;
20
+ /** Include description in completions where supported (default: true) */
21
+ includeDescriptions?: boolean;
22
+ }
23
+ /**
24
+ * Information about a completable option
25
+ */
26
+ interface CompletableOption {
27
+ /** Long option name (e.g., "verbose") */
28
+ name: string;
29
+ /** CLI name (kebab-case, e.g., "dry-run") */
30
+ cliName: string;
31
+ /** Short alias (e.g., "v") */
32
+ alias?: string | undefined;
33
+ /** Description for completion */
34
+ description?: string | undefined;
35
+ /** Whether this option takes a value */
36
+ takesValue: boolean;
37
+ /** Type of value expected */
38
+ valueType: "string" | "number" | "boolean" | "array" | "unknown";
39
+ /** Whether the option is required */
40
+ required: boolean;
41
+ }
42
+ /**
43
+ * Information about a subcommand for completion
44
+ */
45
+ interface CompletableSubcommand {
46
+ /** Subcommand name */
47
+ name: string;
48
+ /** Subcommand description */
49
+ description?: string | undefined;
50
+ /** Nested subcommands */
51
+ subcommands: CompletableSubcommand[];
52
+ /** Options for this subcommand */
53
+ options: CompletableOption[];
54
+ }
55
+ /**
56
+ * Extracted completion data from a command
57
+ */
58
+ interface CompletionData {
59
+ /** The root command */
60
+ command: CompletableSubcommand;
61
+ /** Program name */
62
+ programName: string;
63
+ /** Global options (available to all subcommands) */
64
+ globalOptions: CompletableOption[];
65
+ }
66
+ /**
67
+ * Result of completion generation
68
+ */
69
+ interface CompletionResult {
70
+ /** The generated completion script */
71
+ script: string;
72
+ /** The shell type this script is for */
73
+ shell: ShellType;
74
+ /** Instructions for installing the completion */
75
+ installInstructions: string;
76
+ }
77
+ /**
78
+ * Generator function type for shell completions
79
+ */
80
+ type CompletionGenerator = (command: AnyCommand, options: CompletionOptions) => CompletionResult;
81
+ //#endregion
82
+ //#region src/completion/extractor.d.ts
83
+ /**
84
+ * Extract positional arguments from a command
85
+ */
86
+ declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
87
+ /**
88
+ * Extract completion data from a command tree
89
+ */
90
+ declare function extractCompletionData(command: AnyCommand, programName: string): CompletionData;
91
+ //#endregion
92
+ //#region src/completion/index.d.ts
93
+
94
+ /**
95
+ * Generate completion script for the specified shell
96
+ */
97
+ declare function generateCompletion(command: AnyCommand, options: CompletionOptions): CompletionResult;
98
+ /**
99
+ * Get the list of supported shells
100
+ */
101
+ declare function getSupportedShells(): ShellType[];
102
+ /**
103
+ * Detect the current shell from environment
104
+ */
105
+ declare function detectShell(): ShellType | null;
106
+ /**
107
+ * Schema for the completion command arguments
108
+ */
109
+ declare const completionArgsSchema: z.ZodObject<{
110
+ shell: z.ZodOptional<z.ZodEnum<{
111
+ bash: "bash";
112
+ zsh: "zsh";
113
+ fish: "fish";
114
+ }>>;
115
+ instructions: z.ZodDefault<z.ZodBoolean>;
116
+ }, z.core.$strip>;
117
+ type CompletionArgs = z.infer<typeof completionArgsSchema>;
118
+ /**
119
+ * Create a completion subcommand for your CLI
120
+ *
121
+ * This creates a ready-to-use subcommand that generates completion scripts.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const mainCommand = defineCommand({
126
+ * name: "mycli",
127
+ * subCommands: {
128
+ * completion: createCompletionCommand(mainCommand, "mycli")
129
+ * }
130
+ * });
131
+ * ```
132
+ */
133
+ declare function createCompletionCommand(rootCommand: AnyCommand, programName: string): Command<typeof completionArgsSchema, CompletionArgs, any>;
134
+ /**
135
+ * Helper to add completion command to an existing command's subCommands
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const command = defineCommand({
140
+ * name: "mycli",
141
+ * subCommands: {
142
+ * ...withCompletionCommand(command, "mycli"),
143
+ * // other subcommands
144
+ * }
145
+ * });
146
+ * ```
147
+ */
148
+ declare function withCompletionCommand(rootCommand: AnyCommand, programName: string): {
149
+ completion: ReturnType<typeof createCompletionCommand>;
150
+ };
151
+ //#endregion
152
+ export { type CompletableOption, type CompletableSubcommand, type CompletionData, type CompletionGenerator, type CompletionOptions, type CompletionResult, type ShellType, createCompletionCommand, detectShell, extractCompletionData, extractPositionals, generateCompletion, getSupportedShells, withCompletionCommand };
153
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/completion/types.ts","../../src/completion/extractor.ts","../../src/completion/index.ts"],"sourcesContent":[],"mappings":";;;;;AASA;AAKA;AAcA;AAoBiB,KAvCL,SAAA,GAuCK,MAAqB,GAAA,KAAA,GAMvB,MAAA;AAQ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,GAAiB,CAAA,CAAE,aAAa;;;;;;;;;;;;;;;;iBAiBrB,uBAAA,cACD,kCAGZ,eAAe,sBAAsB;;;;;;;;;;;;;;;iBA4CxB,qBAAA,cACD;cAEE,kBAAkB"}
@@ -0,0 +1,153 @@
1
+ import { d as Command, n as ResolvedFieldMeta, s as AnyCommand } from "../schema-extractor-kkajLb9E.js";
2
+ import { z } from "zod";
3
+
4
+ //#region src/completion/types.d.ts
5
+
6
+ /**
7
+ * Supported shell types for completion
8
+ */
9
+ type ShellType = "bash" | "zsh" | "fish";
10
+ /**
11
+ * Options for completion generation
12
+ */
13
+ interface CompletionOptions {
14
+ /** The shell type to generate completion for */
15
+ shell: ShellType;
16
+ /** The command name as it will be invoked */
17
+ programName: string;
18
+ /** Include subcommand completions (default: true) */
19
+ includeSubcommands?: boolean;
20
+ /** Include description in completions where supported (default: true) */
21
+ includeDescriptions?: boolean;
22
+ }
23
+ /**
24
+ * Information about a completable option
25
+ */
26
+ interface CompletableOption {
27
+ /** Long option name (e.g., "verbose") */
28
+ name: string;
29
+ /** CLI name (kebab-case, e.g., "dry-run") */
30
+ cliName: string;
31
+ /** Short alias (e.g., "v") */
32
+ alias?: string | undefined;
33
+ /** Description for completion */
34
+ description?: string | undefined;
35
+ /** Whether this option takes a value */
36
+ takesValue: boolean;
37
+ /** Type of value expected */
38
+ valueType: "string" | "number" | "boolean" | "array" | "unknown";
39
+ /** Whether the option is required */
40
+ required: boolean;
41
+ }
42
+ /**
43
+ * Information about a subcommand for completion
44
+ */
45
+ interface CompletableSubcommand {
46
+ /** Subcommand name */
47
+ name: string;
48
+ /** Subcommand description */
49
+ description?: string | undefined;
50
+ /** Nested subcommands */
51
+ subcommands: CompletableSubcommand[];
52
+ /** Options for this subcommand */
53
+ options: CompletableOption[];
54
+ }
55
+ /**
56
+ * Extracted completion data from a command
57
+ */
58
+ interface CompletionData {
59
+ /** The root command */
60
+ command: CompletableSubcommand;
61
+ /** Program name */
62
+ programName: string;
63
+ /** Global options (available to all subcommands) */
64
+ globalOptions: CompletableOption[];
65
+ }
66
+ /**
67
+ * Result of completion generation
68
+ */
69
+ interface CompletionResult {
70
+ /** The generated completion script */
71
+ script: string;
72
+ /** The shell type this script is for */
73
+ shell: ShellType;
74
+ /** Instructions for installing the completion */
75
+ installInstructions: string;
76
+ }
77
+ /**
78
+ * Generator function type for shell completions
79
+ */
80
+ type CompletionGenerator = (command: AnyCommand, options: CompletionOptions) => CompletionResult;
81
+ //#endregion
82
+ //#region src/completion/extractor.d.ts
83
+ /**
84
+ * Extract positional arguments from a command
85
+ */
86
+ declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
87
+ /**
88
+ * Extract completion data from a command tree
89
+ */
90
+ declare function extractCompletionData(command: AnyCommand, programName: string): CompletionData;
91
+ //#endregion
92
+ //#region src/completion/index.d.ts
93
+
94
+ /**
95
+ * Generate completion script for the specified shell
96
+ */
97
+ declare function generateCompletion(command: AnyCommand, options: CompletionOptions): CompletionResult;
98
+ /**
99
+ * Get the list of supported shells
100
+ */
101
+ declare function getSupportedShells(): ShellType[];
102
+ /**
103
+ * Detect the current shell from environment
104
+ */
105
+ declare function detectShell(): ShellType | null;
106
+ /**
107
+ * Schema for the completion command arguments
108
+ */
109
+ declare const completionArgsSchema: z.ZodObject<{
110
+ shell: z.ZodOptional<z.ZodEnum<{
111
+ bash: "bash";
112
+ zsh: "zsh";
113
+ fish: "fish";
114
+ }>>;
115
+ instructions: z.ZodDefault<z.ZodBoolean>;
116
+ }, z.core.$strip>;
117
+ type CompletionArgs = z.infer<typeof completionArgsSchema>;
118
+ /**
119
+ * Create a completion subcommand for your CLI
120
+ *
121
+ * This creates a ready-to-use subcommand that generates completion scripts.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const mainCommand = defineCommand({
126
+ * name: "mycli",
127
+ * subCommands: {
128
+ * completion: createCompletionCommand(mainCommand, "mycli")
129
+ * }
130
+ * });
131
+ * ```
132
+ */
133
+ declare function createCompletionCommand(rootCommand: AnyCommand, programName: string): Command<typeof completionArgsSchema, CompletionArgs, any>;
134
+ /**
135
+ * Helper to add completion command to an existing command's subCommands
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const command = defineCommand({
140
+ * name: "mycli",
141
+ * subCommands: {
142
+ * ...withCompletionCommand(command, "mycli"),
143
+ * // other subcommands
144
+ * }
145
+ * });
146
+ * ```
147
+ */
148
+ declare function withCompletionCommand(rootCommand: AnyCommand, programName: string): {
149
+ completion: ReturnType<typeof createCompletionCommand>;
150
+ };
151
+ //#endregion
152
+ export { type CompletableOption, type CompletableSubcommand, type CompletionData, type CompletionGenerator, type CompletionOptions, type CompletionResult, type ShellType, createCompletionCommand, detectShell, extractCompletionData, extractPositionals, generateCompletion, getSupportedShells, withCompletionCommand };
153
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/completion/types.ts","../../src/completion/extractor.ts","../../src/completion/index.ts"],"sourcesContent":[],"mappings":";;;;;AASA;AAKA;AAcA;AAoBiB,KAvCL,SAAA,GAuCK,MAAqB,GAAA,KAAA,GAMvB,MAAA;AAQf;AAYA;AAYA;AACW,UAzEM,iBAAA,CAyEN;EACA;EACN,KAAA,EAzEI,SAyEJ;EAAgB;;;;EChDL;EA4CA,mBAAA,CAAA,EAAA,OAAqB;;;;AClCrC;AACW,UFxBM,iBAAA,CEwBN;EACA;EACR,IAAA,EAAA,MAAA;EAAgB;EAgBH,OAAA,EAAA,MAAA;EAOA;EAoBV,KAAA,CAAA,EAAA,MAAA,GAAA,SAgBJ;;;;;;EAhBwB,SAAA,EAAA,QAAA,GAAA,QAAA,GAAA,SAAA,GAAA,OAAA,GAAA,SAAA;EAAA;EAkBrB,QAAA,EAAA,OAAc;AAiBnB;;;;AAIG,UFxFc,qBAAA,CEwFd;EAAO;EA4CM,IAAA,EAAA,MAAA;EACD;EAEoB,WAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAAlB;EAAU,W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