@@ -15,16 +15,31 @@ process.removeAllListeners('uncaughtException');
15
15
var commander = require ( 'commander' ) ;
16
16
17
17
const program = new commander . Command ( ) ;
18
+ const commanderParseInt = function ( value ) {
19
+ const parsedValue = parseInt ( value , 10 ) ;
20
+ if ( isNaN ( parsedValue ) ) {
21
+ throw new commander . InvalidArgumentError ( "Not a valid integer." ) ;
22
+ }
23
+ return parsedValue ;
24
+ } ;
25
+
18
26
program . name ( 'solcjs' ) ;
19
27
program . version ( solc . version ( ) ) ;
20
28
program
21
29
. option ( '--version' , 'Show version and exit.' )
22
30
. option ( '--optimize' , 'Enable bytecode optimizer.' , false )
31
+ . option (
32
+ '--optimize-runs <optimize-runs>' ,
33
+ 'The number of runs specifies roughly how often each opcode of the deployed code will be executed across the lifetime of the contract. ' +
34
+ 'Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage.' ,
35
+ commanderParseInt
36
+ )
23
37
. option ( '--bin' , 'Binary of the contracts in hex.' )
24
38
. option ( '--abi' , 'ABI of the contracts.' )
25
39
. option ( '--standard-json' , 'Turn on Standard JSON Input / Output mode.' )
26
40
. option ( '--base-path <path>' , 'Automatically resolve all imports inside the given path.' )
27
41
. option ( '-o, --output-dir <output-directory>' , 'Output directory for the contracts.' ) ;
42
+
28
43
program . parse ( process . argv ) ;
29
44
const options = program . opts ( ) ;
30
45
@@ -131,7 +146,8 @@ var output = JSON.parse(solc.compile(JSON.stringify({
131
146
language : 'Solidity' ,
132
147
settings : {
133
148
optimizer : {
134
- enabled : options . optimize
149
+ enabled : options . optimize ,
150
+ runs : options . optimizeRuns ,
135
151
} ,
136
152
outputSelection : {
137
153
'*' : {
0 commit comments