Skip to content

Commit aa49a83

Browse files
committed
solcjs: Add --verbose option
1 parent bbab02b commit aa49a83

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

solcjs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ program
3939
.option('--standard-json', 'Turn on Standard JSON Input / Output mode.')
4040
.option('--base-path <path>', 'Automatically resolve all imports inside the given path.')
4141
.option('-o, --output-dir <output-directory>', 'Output directory for the contracts.')
42-
.option('-p, --pretty-json', 'Pretty-print all JSON output.', false);
42+
.option('-p, --pretty-json', 'Pretty-print all JSON output.', false)
43+
.option('-v, --verbose', 'More detailed console output.', false);
4344

4445
program.parse(process.argv);
4546
const options = program.opts();
@@ -106,11 +107,15 @@ if (options.basePath || !options.standardJson)
106107

107108
if (options.standardJson) {
108109
var input = fs.readFileSync(process.stdin.fd).toString('utf8');
110+
if (program.verbose)
111+
console.log('>>> Compiling:\n' + reformatJsonIfRequested(input) + "\n")
109112
var output = reformatJsonIfRequested(solc.compile(input, callbacks));
110113

111114
try {
112115
var inputJSON = smtchecker.handleSMTQueries(JSON.parse(input), JSON.parse(output), smtsolver.smtSolver);
113116
if (inputJSON) {
117+
if (program.verbose)
118+
console.log('>>> Retrying compilation with SMT:\n' + toFormattedJson(inputJSON) + "\n")
114119
output = reformatJsonIfRequested(solc.compile(JSON.stringify(inputJSON), callbacks));
115120
}
116121
}
@@ -130,6 +135,8 @@ if (options.standardJson) {
130135
output = toFormattedJson(outputJSON);
131136
}
132137

138+
if (program.verbose)
139+
console.log('>>> Compilation result:')
133140
console.log(output);
134141
process.exit(0);
135142
} else if (files.length === 0) {
@@ -151,7 +158,7 @@ for (var i = 0; i < files.length; i++) {
151158
}
152159
}
153160

154-
var output = JSON.parse(solc.compile(JSON.stringify({
161+
const cliInput = {
155162
language: 'Solidity',
156163
settings: {
157164
optimizer: {
@@ -165,7 +172,10 @@ var output = JSON.parse(solc.compile(JSON.stringify({
165172
}
166173
},
167174
sources: sources
168-
}), callbacks));
175+
};
176+
if (program.verbose)
177+
console.log('>>> Compiling:\n' + toFormattedJson(cliInput) + "\n")
178+
var output = JSON.parse(solc.compile(JSON.stringify(cliInput), callbacks));
169179

170180
let hasError = false;
171181

0 commit comments

Comments
 (0)