-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.ts
52 lines (48 loc) · 1.93 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
import { compileCircuitDir, testCircuitDir } from './index';
import { Command } from 'commander';
async function main() {
try {
const program = new Command();
program.version('0.0.11');
program
.command('compile <circuit_dir>')
.description('compile a circom circuit dir')
.option('-f, --force_recompile', 'ignore compiled files', false)
.option('-s, --sanity_check', 'check constraints when generate witness', false)
.option('-v, --verbose', 'print verbose log', false)
.option('-b, --backend <string>', 'native|wasm|auto', 'auto')
.action(async (circuit_dir, options) => {
await compileCircuitDir(circuit_dir, {
alwaysRecompile: options.force_recompile,
verbose: options.verbose,
backend: options.backend,
sanityCheck: options.sanity_check,
});
});
program
.command('check <circuit_dir>')
.alias('test')
.option('-d, --data_dir <string>', 'all input.json/output.json inside this dir will be tested', '')
.option('-f, --force_recompile', 'ignore compiled files', false)
.option('-s, --sanity_check', 'check constraints when generate witness', false)
.option('-v, --verbose', 'print verbose log', false)
.option('-b, --backend <string>', 'native|wasm|auto', 'auto')
.option('-w, --witness_type <string>', 'bin or text', 'text')
.description('test a circom circuit with given inputs/outputs')
.action(async (circuit_dir, options) => {
await testCircuitDir(circuit_dir, options.data_dir, {
alwaysRecompile: options.force_recompile,
verbose: options.verbose,
backend: options.backend,
witnessFileType: options.witness_type,
sanityCheck: options.sanity_check,
});
});
await program.parseAsync(process.argv);
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
}
main();