arnaucube
arnaucube/circomPublic Self-hosted repository
circom/cli.js
cli.jsRaw
 1#!/usr/bin/env node
 2
 3/*
 4    Copyright 2018 0kims association
 5
 6    This file is part of jaz (Zero Knowlage Circuit compiler).
 7
 8    jaz is free software: you can redistribute it and/or modify
 9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12
13    jaz is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with jaz.  If not, see <https://www.gnu.org/licenses/>.
20*/
21
22/* eslint-disable no-console */
23
24const fs = require("fs");
25const path = require("path");
26
27const compiler = require("./src/compiler");
28
29const argv = require("yargs")
30    .version(function() {
31        return require("./package").version;
32    })
33    .usage("jaz -s [input source circuit file] -o [output definition circuit file]")
34    .alias("s", "source")
35    .alias("o", "output")
36    .require(["s","o"])
37    .help("h")
38    .alias("h", "help")
39    .epilogue(`Copyright (C) 2018  0kims association
40    This program comes with ABSOLUTELY NO WARRANTY;
41    This is free software, and you are welcome to redistribute it
42    under certain conditions; see the COPYING file in the official
43    repo directory at  https://github.com/iden3/jaz `)
44    .argv;
45
46const fullFileName = path.resolve(process.cwd(), argv.source);
47
48compiler(fullFileName).then( (cir) => {
49    fs.writeFileSync(argv.output, JSON.stringify(cir, null, 1), "utf8");
50}, (err) => {
51    console.error(`ERROR at ${err.errFile}:${err.pos.first_line},${err.pos.first_column}-${err.pos.last_line},${err.pos.last_column}   ${err.errStr}`);
52    console.error(JSON.stringify(err.ast, null, 1));
53    process.exit(1);
54});
55
56
57
58