Skip to content

Commit d268ffa

Browse files
author
Micah Zoltu
committed
Replaces yargs with commander.
Works towards resolving #361. Yargs brings in ~26 packages while commander brings in 1.
1 parent edfb717 commit d268ffa

File tree

2 files changed

+24
-43
lines changed

2 files changed

+24
-43
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
"homepage": "https://github.com/ethereum/solc-js#readme",
4343
"dependencies": {
4444
"command-exists": "^1.2.8",
45+
"commander": "3.0.2",
4546
"fs-extra": "^0.30.0",
47+
"js-sha3": "0.8.0",
4648
"memorystream": "^0.3.1",
4749
"require-from-string": "^2.0.0",
4850
"semver": "^5.5.0",
49-
"js-sha3": "0.8.0",
50-
"tmp": "0.0.33",
51-
"yargs": "^13.2.0"
51+
"tmp": "0.0.33"
5252
},
5353
"devDependencies": {
5454
"coveralls": "^3.0.0",

solcjs

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,29 @@ var smtsolver = require('./smtsolver.js');
1111
// FIXME: remove annoying exception catcher of Emscripten
1212
// see https://github.com/chriseth/browser-solidity/issues/167
1313
process.removeAllListeners('uncaughtException');
14-
15-
var yargs = require('yargs')
16-
.usage('Usage: $0 [options] [input_file...]')
17-
.option('version', {
18-
describe: 'Show version and exit.',
19-
type: 'boolean'
20-
})
21-
.option('optimize', {
22-
describe: 'Enable bytecode optimizer.',
23-
type: 'boolean'
24-
})
25-
.option('bin', {
26-
describe: 'Binary of the contracts in hex.',
27-
type: 'boolean'
28-
})
29-
.option('abi', {
30-
describe: 'ABI of the contracts.',
31-
type: 'boolean'
32-
})
33-
.option('standard-json', {
34-
describe: 'Turn on Standard JSON Input / Output mode.',
35-
type: 'boolean'
36-
})
37-
.option('output-dir', {
38-
alias: 'o',
39-
describe: 'Output directory for the contracts.',
40-
type: 'string'
41-
})
42-
.version(solc.version())
43-
.showHelpOnFail(false, 'Specify --help for available options')
44-
.help()
45-
46-
var argv = yargs.argv;
47-
var files = argv._;
48-
var destination = argv['output-dir'] || '.'
14+
var commander = require('commander');
15+
16+
var program = new commander.Command();
17+
program.name('solcjs');
18+
program.version(solc.version());
19+
program
20+
.option('--version', 'Show version and exit.')
21+
.option('--optimize', 'Enable bytecode optimizer.')
22+
.option('--bin', 'Binary of the contracts in hex.')
23+
.option('--abi', 'ABI of the contracts.')
24+
.option('--standard-json', 'Turn on Standard JSON Input / Output mode.')
25+
.option('-o, --output-dir <output-directory>', 'Output directory for the contracts.');
26+
program.parse(process.argv);
27+
28+
var files = program.args;
29+
var destination = program.outputDir || '.'
4930

5031
function abort (msg) {
5132
console.error(msg || 'Error occured');
5233
process.exit(1);
5334
}
5435

55-
if (argv['standard-json']) {
36+
if (program.standardJson) {
5637
var input = fs.readFileSync(process.stdin.fd).toString('utf8');
5738
var output = solc.compileStandardWrapper(input);
5839

@@ -85,7 +66,7 @@ if (argv['standard-json']) {
8566
process.exit(1);
8667
}
8768

88-
if (!(argv.bin || argv.abi)) {
69+
if (!(program.bin || program.abi)) {
8970
abort('Invalid option selected, must specify either --bin or --abi');
9071
}
9172

@@ -103,7 +84,7 @@ var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify({
10384
language: 'Solidity',
10485
settings: {
10586
optimizer: {
106-
enabled: argv.optimize
87+
enabled: program.optimize
10788
},
10889
outputSelection: {
10990
'*': {
@@ -146,11 +127,11 @@ for (var fileName in output.contracts) {
146127
var contractFileName = fileName + ':' + contractName;
147128
contractFileName = contractFileName.replace(/[:./\\]/g, '_');
148129

149-
if (argv.bin) {
130+
if (program.bin) {
150131
writeFile(contractFileName + '.bin', output.contracts[fileName][contractName].evm.bytecode.object);
151132
}
152133

153-
if (argv.abi) {
134+
if (program.abi) {
154135
writeFile(contractFileName + '.abi', JSON.stringify(output.contracts[fileName][contractName].abi));
155136
}
156137
}

0 commit comments

Comments
 (0)