Skip to content

Commit 6ea5686

Browse files
committed
prettier
1 parent d8f14d6 commit 6ea5686

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

examples/demo.cac.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cli
4343
console.log('Serve options:', options);
4444
});
4545

46-
cli.command('dev build', 'Build project').action((options) => { });
46+
cli.command('dev build', 'Build project').action((options) => {});
4747

4848
cli
4949
.command('copy <source> <destination>', 'Copy files')

src/cac.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { OptionHandler } from './t';
88
import { CompletionConfig } from './shared';
99
import t from './t';
1010

11-
const noopOptionHandler: OptionHandler = function () { };
11+
const noopOptionHandler: OptionHandler = function () {};
1212

1313
const execPath = process.execPath;
1414
const processArgs = process.argv.slice(1);
@@ -81,11 +81,14 @@ export default async function tab(
8181
const targetCommand = isRootCommand ? t : command;
8282
if (targetCommand) {
8383
// Check if it's a boolean option by looking at the name and config
84-
const isBoolean = !option.name.includes('<') && !option.name.includes('[');
84+
const isBoolean =
85+
!option.name.includes('<') && !option.name.includes('[');
8586

8687
// Handle negatable flags (--no-something)
8788
const isNegatable = option.name.startsWith('--no-');
88-
const cleanName = isNegatable ? option.name.replace('--no-', '') : argName;
89+
const cleanName = isNegatable
90+
? option.name.replace('--no-', '')
91+
: argName;
8992

9093
targetCommand.option(
9194
cleanName, // Store just the option name without -- prefix

src/citty.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function convertOptionHandler(handler: any): OptionHandler {
8585
};
8686
}
8787

88-
const noopOptionHandler: OptionHandler = function () { };
88+
const noopOptionHandler: OptionHandler = function () {};
8989

9090
async function handleSubCommands(
9191
subCommands: SubCommandsDef,
@@ -150,7 +150,8 @@ async function handleSubCommands(
150150
: undefined;
151151

152152
// Add option using t.ts API - store without -- prefix
153-
const isBoolean = conf.type === 'boolean' || (!conf.type && !conf.required);
153+
const isBoolean =
154+
conf.type === 'boolean' || (!conf.type && !conf.required);
154155
command.option(
155156
argName,
156157
conf.description ?? '',

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ export class Completion {
436436

437437
// Handle flag name completion
438438
if (toComplete.startsWith('-')) {
439-
const isShortFlag = toComplete.startsWith('-') && !toComplete.startsWith('--');
439+
const isShortFlag =
440+
toComplete.startsWith('-') && !toComplete.startsWith('--');
440441
const isNegation = toComplete.startsWith('--no-');
441442

442443
for (const [name, option] of command.options) {

src/t.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ export class Command {
9595
alias?: string,
9696
isBoolean: boolean = false
9797
) {
98-
const option = new Option(this, value, description, handler, alias, isBoolean);
98+
const option = new Option(
99+
this,
100+
value,
101+
description,
102+
handler,
103+
alias,
104+
isBoolean
105+
);
99106
this.options.set(value, option);
100107
return this;
101108
}
@@ -229,23 +236,28 @@ export class RootCommand extends Command {
229236

230237
this.completions = toComplete.includes('=')
231238
? suggestions.map((s) => ({
232-
value: `${optionName}=${s.value}`,
233-
description: s.description,
234-
}))
239+
value: `${optionName}=${s.value}`,
240+
description: s.description,
241+
}))
235242
: suggestions;
236243
return;
237244
}
238245
}
239246

240247
// Handle flag name completion
241248
if (toComplete.startsWith('-')) {
242-
const isShortFlag = toComplete.startsWith('-') && !toComplete.startsWith('--');
249+
const isShortFlag =
250+
toComplete.startsWith('-') && !toComplete.startsWith('--');
243251
const cleanToComplete = toComplete.replace(/^-+/, '');
244252
const isNegation = toComplete.startsWith('--no-');
245253

246254
for (const [name, option] of command.options) {
247255
// Handle short flag completion (-v, -d, etc)
248-
if (isShortFlag && option.alias && `-${option.alias}`.startsWith(toComplete)) {
256+
if (
257+
isShortFlag &&
258+
option.alias &&
259+
`-${option.alias}`.startsWith(toComplete)
260+
) {
249261
const description = option.isBoolean
250262
? `[boolean] ${option.description}`
251263
: option.description;
@@ -446,9 +458,9 @@ export class RootCommand extends Command {
446458
setup(name: string, executable: string, shell: string) {
447459
assert(
448460
shell === 'zsh' ||
449-
shell === 'bash' ||
450-
shell === 'fish' ||
451-
shell === 'powershell',
461+
shell === 'bash' ||
462+
shell === 'fish' ||
463+
shell === 'powershell',
452464
'Unsupported shell'
453465
);
454466

0 commit comments

Comments
 (0)