generated from canisminor1990/canisminor-template
-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathcli.ts
35 lines (28 loc) · 855 Bytes
/
cli.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Command, Option } from 'commander';
import { consola } from 'consola';
import updateNotifier from 'update-notifier';
import packageJson from '@/../package.json';
import Shebang from '@/commands/Shebang';
const notifier = updateNotifier({
pkg: packageJson,
shouldNotifyInNpmScript: true,
});
notifier.notify({ isGlobal: true });
const program = new Command();
program
.name('lobe-shebang')
.description(packageJson.description)
.version(packageJson.version)
.addOption(new Option('-t, --target <file>', 'Target file'))
.addOption(new Option('-s, --shebang <string>', 'Shebang'))
.parse();
interface Flags {
shebang?: string;
target?: string;
}
const options: Flags = program.opts();
if (options.target) {
Shebang(options.target, options.shebang);
} else {
consola.error('Please input target file with -t <file>');
}