-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcli.js
executable file
·84 lines (76 loc) · 3.26 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env node
const { program } = require('commander');
program.version(require('./package.json').version);
const { create, upload, remove, setDefault, download } = require("./src");
program
.option('-p, --privateKey [privateKey]', 'private key')
.option('-a, --address [address]', 'flat directory address')
.option('-f, --file [file]', 'upload file path/name')
.option('-c, --chainId [chainId]', 'chain id')
.option('-r, --rpc [rpc]', 'provider url')
.option('-t, --type [type]', 'uploader type')
.option('-g, --gasIncPct [gasIncPct]', 'gas price increase percentage')
.option('-s, --threadPoolSize [threadPoolSize]', 'thread pool size')
.option('-e, --estimateGas [estimateGas]', 'estimate gas');
program
.command('create')
.description('deploy flat directory')
.option('-p, --privateKey <privateKey>', 'private key')
.option('-c, --chainId [chainId]', 'chain id')
.option('-r, --rpc [rpc]', 'provider url')
.action(() => {
const opts = program.opts();
create(opts.privateKey, opts.chainId, opts.rpc);
});
program
.command('default')
.description('set default file')
.option('-p, --privateKey <privateKey>', 'private key')
.option('-a, --address <address>', 'flat directory address')
.option('-f, --file <file>', 'file name')
.option('-c, --chainId [chainId]', 'chain id')
.option('-r, --rpc [rpc]', 'provider url')
.action(() => {
const opts = program.opts();
setDefault(opts.privateKey, opts.address, opts.file, opts.rpc, opts.chainId);
});
program
.command('remove')
.description('remove file')
.option('-p, --privateKey <privateKey>', 'private key')
.option('-a, --address <address>', 'flat directory address')
.option('-f, --file <file>', 'file name')
.option('-c, --chainId [chainId]', 'chain id')
.option('-r, --rpc [rpc]', 'provider url')
.action(() => {
const opts = program.opts();
remove(opts.privateKey, opts.address, opts.file, opts.rpc, opts.chainId);
});
program
.command('download')
.description('download file')
.option('-a, --address <address>', 'flat directory address')
.option('-f, --file <file>', 'file name')
.option('-c, --chainId [chainId]', 'chain id')
.option('-r, --rpc [rpc]', 'provider url')
.action(() => {
const opts = program.opts();
download(opts.address, opts.file, opts.rpc, opts.chainId);
});
program
.command('upload')
.description('deploy file|directory')
.option('-p, --privateKey <privateKey>', 'private key')
.option('-a, --address <address>', 'flat directory address')
.option('-f, --file <file>', 'upload file|directory path')
.option('-t, --type [type]', 'uploader type')
.option('-c, --chainId [chainId]', 'chain id')
.option('-r, --rpc [rpc]', 'provider url')
.option('-g, --gasIncPct [gasIncPct]', 'gas price increase percentage')
.option('-e, --estimateGas [estimateGas]', 'estimate gas')
.option('-s, --threadPoolSize [threadPoolSize]', 'thread pool size')
.action(() => {
const opts = program.opts();
upload(opts.privateKey, opts.address, opts.file, opts.type, opts.rpc, opts.chainId, opts.gasIncPct, opts.threadPoolSize, opts.estimateGas);
});
program.parse(process.argv);