Skip to content

Commit fbea9ca

Browse files
committed
cleanup: format
1 parent 44a2993 commit fbea9ca

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/cac.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function tab(instance: CAC): Completion {
4141
for (const option of [...instance.globalCommand.options, ...cmd.options]) {
4242
// Extract short flag from the name if it exists (e.g., "-c, --config" -> "c")
4343
const shortFlag = option.name.match(/^-([a-zA-Z]), --/)?.[1];
44-
44+
4545
completion.addOption(
4646
commandName,
4747
`--${option.name.replace(/^-[a-zA-Z], --/, '')}`, // Remove the short flag part if it exists

src/citty.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ async function handleSubCommands<T extends ArgsDef = ArgsDef>(
6666
continue;
6767
}
6868
// Extract alias from the config if it exists
69-
const shortFlag = typeof conf === 'object' && 'alias' in conf ?
70-
(Array.isArray(conf.alias) ? conf.alias[0] : conf.alias) :
71-
undefined;
72-
69+
const shortFlag =
70+
typeof conf === 'object' && 'alias' in conf
71+
? Array.isArray(conf.alias)
72+
? conf.alias[0]
73+
: conf.alias
74+
: undefined;
75+
7376
completion.addOption(
7477
name,
7578
`--${argName}`,

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export class Completion {
284284
}
285285
}
286286
}
287-
287+
288288
if (option) {
289289
const suggestions = await option.handler(
290290
previousArgs,
@@ -306,8 +306,9 @@ export class Completion {
306306

307307
// Handle flag name completion
308308
if (toComplete.startsWith('-')) {
309-
const isShortFlag = toComplete.startsWith('-') && !toComplete.startsWith('--');
310-
309+
const isShortFlag =
310+
toComplete.startsWith('-') && !toComplete.startsWith('--');
311+
311312
for (const [name, option] of command.options) {
312313
// For short flags (-), only show aliases
313314
if (isShortFlag) {

tests/cli.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describe.each(cliTools)('cli completion tests for %s', (cliTool) => {
2727
describe('cli option completion tests', () => {
2828
const optionTests = [
2929
{ partial: '--p', expected: '--port' },
30-
{ partial: '-p', expected: '-p' }, // Test short flag completion
31-
{ partial: '-H', expected: '-H' }, // Test another short flag completion
30+
{ partial: '-p', expected: '-p' }, // Test short flag completion
31+
{ partial: '-H', expected: '-H' }, // Test another short flag completion
3232
];
3333

3434
test.each(optionTests)(

0 commit comments

Comments
 (0)