Skip to content

Commit dbf8461

Browse files
committed
pnpm install
2 parents 5cd4db0 + fa066b9 commit dbf8461

File tree

7 files changed

+350
-354
lines changed

7 files changed

+350
-354
lines changed

demo.citty.ts

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -60,63 +60,68 @@ main.subCommands = {
6060
lint: lintCommand,
6161
} as Record<string, CommandDef<ArgsDef>>;
6262

63-
const completion = await tab(main);
64-
65-
for (const command of completion.commands.values()) {
66-
if (command.name === 'lint') {
67-
command.handler = () => {
68-
return [
69-
{ value: 'main.ts', description: 'Main file' },
70-
{ value: 'index.ts', description: 'Index file' },
71-
];
72-
};
73-
}
74-
75-
for (const [o, config] of command.options.entries()) {
76-
if (o === '--port') {
77-
config.handler = () => {
78-
return [
79-
{ value: '3000', description: 'Development server port' },
80-
{ value: '8080', description: 'Alternative port' },
81-
];
82-
};
83-
}
84-
if (o === '--host') {
85-
config.handler = () => {
63+
const completion = await tab(main, {
64+
subCommands: {
65+
lint: {
66+
handler() {
8667
return [
87-
{ value: 'localhost', description: 'Localhost' },
88-
{ value: '0.0.0.0', description: 'All interfaces' },
68+
{ value: 'main.ts', description: 'Main file' },
69+
{ value: 'index.ts', description: 'Index file' },
8970
];
90-
};
91-
}
92-
if (o === '--config') {
93-
config.handler = () => {
71+
},
72+
},
73+
dev: {
74+
options: {
75+
port: {
76+
handler() {
77+
return [
78+
{ value: '3000', description: 'Development server port' },
79+
{ value: '8080', description: 'Alternative port' },
80+
];
81+
},
82+
},
83+
host: {
84+
handler() {
85+
return [
86+
{ value: 'localhost', description: 'Localhost' },
87+
{ value: '0.0.0.0', description: 'All interfaces' },
88+
];
89+
},
90+
},
91+
},
92+
},
93+
},
94+
options: {
95+
config: {
96+
handler() {
9497
return [
9598
{ value: 'vite.config.ts', description: 'Vite config file' },
9699
{ value: 'vite.config.js', description: 'Vite config file' },
97100
];
98-
};
99-
}
100-
if (o === '--mode') {
101-
config.handler = () => {
101+
},
102+
},
103+
mode: {
104+
handler() {
102105
return [
103106
{ value: 'development', description: 'Development mode' },
104107
{ value: 'production', description: 'Production mode' },
105108
];
106-
};
107-
}
108-
if (o === '--logLevel') {
109-
config.handler = () => {
109+
},
110+
},
111+
logLevel: {
112+
handler() {
110113
return [
111114
{ value: 'info', description: 'Info level' },
112115
{ value: 'warn', description: 'Warn level' },
113116
{ value: 'error', description: 'Error level' },
114117
{ value: 'silent', description: 'Silent level' },
115118
];
116-
};
117-
}
118-
}
119-
}
119+
},
120+
},
121+
},
122+
});
123+
124+
completion;
120125

121126
const cli = createMain(main);
122127

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@
2828
"prettier": "^3.5.2",
2929
"tsup": "^8.3.6",
3030
"tsx": "^4.19.1",
31-
"typescript-eslint": "^8.25.0",
31+
"typescript": "^5.7.3",
3232
"vitest": "^2.1.3"
3333
},
3434
"dependencies": {
3535
"mri": "^1.2.0"
3636
},
3737
"exports": {
3838
".": {
39+
"types": "./dist/index.d.ts",
3940
"import": "./dist/index.js",
40-
"require": "./dist/index.cjs",
41-
"types": "./dist/index.d.ts"
41+
"require": "./dist/index.cjs"
4242
},
4343
"./citty": {
44+
"types": "./dist/citty.d.ts",
4445
"import": "./dist/citty.js",
45-
"require": "./dist/citty.cjs",
46-
"types": "./dist/citty.d.ts"
46+
"require": "./dist/citty.cjs"
4747
},
4848
"./cac": {
49+
"types": "./dist/cac.d.ts",
4950
"import": "./dist/cac.js",
50-
"require": "./dist/cac.cjs",
51-
"types": "./dist/cac.d.ts"
51+
"require": "./dist/cac.cjs"
5252
}
5353
},
5454
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"

0 commit comments

Comments
 (0)