This repository has been archived by the owner on May 25, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.ts
45 lines (38 loc) · 1.35 KB
/
mod.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
36
37
38
39
40
41
42
43
44
45
import { Command, CompletionsCommand, EnumType } from './_deps.ts';
import main from './commands/main.ts';
import cacheControl from './commands/cacheControls.ts';
import upgrade from './commands/upgrade.ts';
import VERSION from './version.ts';
const cmd = new Command()
.name('clank')
.version(VERSION)
.versionOption('-v, --version')
.description('A simple CLI that runs your C++ code just in time')
.arguments<string[]>('<file>')
.type('compilers', new EnumType(['clang++', 'g++']))
.option<{ compiler: 'clang++' | 'g++' }>(
'-c, --compiler <name:compilers>',
'which compiler executable to use',
{ default: Deno.build.os === 'darwin' ? 'clang++' : 'g++' },
)
.option<{ compilerFlags: string[] }>(
'-f, --compiler-flags <flags>',
'flags to pass to the compiler',
{ collect: true, default: ['-O2', '-Wall', '--std=c++14'] },
)
.example('Compile and run', 'clank sth.cpp')
.example('Compile using g++ on macOS and run', 'clank sth.cpp -c g++')
.example(
'Compile with -O2 and all warnings and run',
'clank sth.cpp -f -O2 -f -Wall',
)
.action(main);
cmd.command('cache', cacheControl);
cmd.command('upgrade')
.description('upgrade clank to the latest version')
.action(upgrade);
cmd.command(
'completions',
new CompletionsCommand().description('generate shell completions'),
);
await cmd.parse(Deno.args);