Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
const fs = require("fs");
const path = require("path");

const compiler = require("./src/compiler");
const compiler = require("./src/compiler").compile;

const version = require("./package").version;

const argv = require("yargs")
.version(version)
.usage("circom [input source circuit file] -o [output definition circuit file]")
.usage("circom [input source circuit file] -o [output definition circuit file] -d [directory to save the compiled file]")
.alias("o", "output")
.alias("d", "directory")
.help("h")
.alias("h", "help")
.alias("v", "verbose")
Expand All @@ -47,20 +48,22 @@ let inputFile;
if (argv._.length == 0) {
inputFile = "circuit.circom";
} else if (argv._.length == 1) {

inputFile = argv._[0];
} else {
} else {
console.log("Only one circuit at a time is permited");
process.exit(1);
}

const fullFileName = path.resolve(process.cwd(), inputFile);
const outName = argv.output ? argv.output : "circuit.json";
const outName = argv.output ? argv.output : "circuit.json";
const directoryToSave = argv.directory ? argv.directory : './';

compiler(fullFileName).then( (cir) => {
fs.writeFileSync(outName, JSON.stringify(cir, null, 1), "utf8");
compiler(fullFileName).then((cir) => {
fs.writeFileSync(`${directoryToSave}/${outName}`, JSON.stringify(cir, null, 1), "utf8");
process.exit(0);
}, (err) => {
// console.log(err);
// console.log(err);
console.log(err.stack);
if (err.pos) {
console.error(`ERROR at ${err.errFile}:${err.pos.first_line},${err.pos.first_column}-${err.pos.last_line},${err.pos.last_column} ${err.errStr}`);
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
module.exports = require("./src/compiler.js");
const compile = require("./src/compiler.js").compile;
module.exports = {
compile
}
Loading