Skip to content

Commit

Permalink
refactor: use CAC
Browse files Browse the repository at this point in the history
  • Loading branch information
thenbe committed Jun 8, 2023
1 parent b6d1806 commit 4faa49e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"dependencies": {
"@clack/prompts": "0.6.3",
"cac": "6.7.14",
"execa": "7.1.1",
"picocolors": "1.0.0"
},
Expand Down
4 changes: 3 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { cancel, intro, isCancel, outro, select } from '@clack/prompts';
import { cac } from 'cac';
import { execa } from 'execa';
import path from 'node:path';
import color from 'picocolors';
Expand Down Expand Up @@ -89,4 +90,18 @@ async function switchWorktree() {
outro(color.green('Success'));
}

await switchWorktree();
function run() {
const cli = cac('worktree-welder');

cli
.command('', 'Switch to another worktree')
.option('--sort [key]', 'Sort method', {
default: 'name',
})
.action(switchWorktree);

cli.help();
cli.parse();
}

run();

0 comments on commit 4faa49e

Please sign in to comment.