aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-compiler/src/cli.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-08-14 09:42:09 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-08-14 09:42:09 +0800
commit88766a02c7e6688e72d5c4c69ce68028b322f154 (patch)
treefa06552a80249e7998691b64df6b3b2827f9f947 /packages/sol-compiler/src/cli.ts
parent8162394797342cef268cc8072fc860326974e269 (diff)
parentfadd292ecf367e42154856509d0ea0c20b23f2f1 (diff)
downloaddexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.gz
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.bz2
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.lz
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.xz
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.zst
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.zip
Merge branch 'development'
Diffstat (limited to 'packages/sol-compiler/src/cli.ts')
-rw-r--r--packages/sol-compiler/src/cli.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/sol-compiler/src/cli.ts b/packages/sol-compiler/src/cli.ts
new file mode 100644
index 000000000..83dadc7ca
--- /dev/null
+++ b/packages/sol-compiler/src/cli.ts
@@ -0,0 +1,44 @@
+#!/usr/bin/env node
+// We need the above pragma since this script will be run as a command-line tool.
+
+import { logUtils } from '@0xproject/utils';
+import * as _ from 'lodash';
+import 'source-map-support/register';
+import * as yargs from 'yargs';
+
+import { Compiler } from './compiler';
+
+const DEFAULT_CONTRACTS_LIST = '*';
+const SEPARATOR = ',';
+
+(async () => {
+ const argv = yargs
+ .option('contracts-dir', {
+ type: 'string',
+ description: 'path of contracts directory to compile',
+ })
+ .option('artifacts-dir', {
+ type: 'string',
+ description: 'path to write contracts artifacts to',
+ })
+ .option('contracts', {
+ type: 'string',
+ description: 'comma separated list of contracts to compile',
+ })
+ .help().argv;
+ const contracts = _.isUndefined(argv.contracts)
+ ? undefined
+ : argv.contracts === DEFAULT_CONTRACTS_LIST
+ ? DEFAULT_CONTRACTS_LIST
+ : argv.contracts.split(SEPARATOR);
+ const opts = {
+ contractsDir: argv.contractsDir,
+ artifactsDir: argv.artifactsDir,
+ contracts,
+ };
+ const compiler = new Compiler(opts);
+ await compiler.compileAsync();
+})().catch(err => {
+ logUtils.log(err);
+ process.exit(1);
+});