Skip to content

Commit 7c9f37c

Browse files
committed
Reduce changes, restore non-functional code
1 parent 660dca6 commit 7c9f37c

2 files changed

Lines changed: 41 additions & 44 deletions

File tree

examples/demo.commander.ts

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -78,49 +78,48 @@ program
7878
const completion = tab(program);
7979

8080
// Configure custom completions
81-
// This needs rewriting with config passed into tab(program)?
82-
// for (const command of completion.commands.values()) {
83-
// if (command.value === 'lint') {
84-
// // Note: Direct handler assignment is not supported in the current API
85-
// // Custom completion logic would need to be implemented differently
86-
// }
81+
for (const command of completion.commands.values()) {
82+
if (command.value === 'lint') {
83+
// Note: Direct handler assignment is not supported in the current API
84+
// Custom completion logic would need to be implemented differently
85+
}
8786

88-
// for (const [option, config] of command.options.entries()) {
89-
// if (option === '--port') {
90-
// config.handler = () => {
91-
// return [
92-
// { value: '3000', description: 'Default port' },
93-
// { value: '8080', description: 'Alternative port' },
94-
// ];
95-
// };
96-
// }
97-
// if (option === '--host') {
98-
// config.handler = () => {
99-
// return [
100-
// { value: 'localhost', description: 'Local development' },
101-
// { value: '0.0.0.0', description: 'All interfaces' },
102-
// ];
103-
// };
104-
// }
105-
// if (option === '--mode') {
106-
// config.handler = () => {
107-
// return [
108-
// { value: 'development', description: 'Development mode' },
109-
// { value: 'production', description: 'Production mode' },
110-
// { value: 'test', description: 'Test mode' },
111-
// ];
112-
// };
113-
// }
114-
// if (option === '--config') {
115-
// config.handler = () => {
116-
// return [
117-
// { value: 'config.json', description: 'JSON config file' },
118-
// { value: 'config.yaml', description: 'YAML config file' },
119-
// ];
120-
// };
121-
// }
122-
// }
123-
// }
87+
for (const [option, config] of command.options.entries()) {
88+
if (option === '--port') {
89+
config.handler = () => {
90+
return [
91+
{ value: '3000', description: 'Default port' },
92+
{ value: '8080', description: 'Alternative port' },
93+
];
94+
};
95+
}
96+
if (option === '--host') {
97+
config.handler = () => {
98+
return [
99+
{ value: 'localhost', description: 'Local development' },
100+
{ value: '0.0.0.0', description: 'All interfaces' },
101+
];
102+
};
103+
}
104+
if (option === '--mode') {
105+
config.handler = () => {
106+
return [
107+
{ value: 'development', description: 'Development mode' },
108+
{ value: 'production', description: 'Production mode' },
109+
{ value: 'test', description: 'Test mode' },
110+
];
111+
};
112+
}
113+
if (option === '--config') {
114+
config.handler = () => {
115+
return [
116+
{ value: 'config.json', description: 'JSON config file' },
117+
{ value: 'config.yaml', description: 'YAML config file' },
118+
];
119+
};
120+
}
121+
}
122+
}
124123

125124
// Parse command line arguments
126125
program.parse();

tests/cli.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ describe.each(cliTools)('cli completion tests for %s', (cliTool) => {
6868
}
6969
);
7070

71-
// Note: on all frameworks, --config is suggested again, which is inconsistent with test title.
7271
it('should not show duplicate options', async () => {
7372
const command = `${commandPrefix} --config vite.config.js --`;
7473
const output = await runCommand(command);
@@ -230,7 +229,6 @@ describe.each(cliTools)('cli completion tests for %s', (cliTool) => {
230229
expect(output).toMatchSnapshot();
231230
});
232231

233-
// Note: on all frameworks, --config is suggested again, which is inconsistent with test title.
234232
it('should not suggest --config after it has been used', async () => {
235233
const command = `${commandPrefix} --config vite.config.ts --`;
236234
const output = await runCommand(command);

0 commit comments

Comments
 (0)