-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathparseArgKeys.js
More file actions
37 lines (36 loc) · 1.03 KB
/
parseArgKeys.js
File metadata and controls
37 lines (36 loc) · 1.03 KB
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
const withKeyArgs = currentYargs => {
return currentYargs
.option("privKey", {
description: "A user private key",
alias: "k",
string: true
})
.option("keyfile", {
description: "An encrypted json keyfile for the user",
alias: "f",
string: true
})
.option("password", {
description: "A password for the encrypted json file",
alias: "p",
string: true
})
.option("mnemonic", {
description: "A mnemonic for the user account",
alias: "mn",
string: true
})
.conflicts("mnemonic", "privKey")
.conflicts("mnemonic", "keyfile")
.conflicts("mnemonic", "password")
.conflicts("password", "privKey")
.conflicts("keyfile", "privKey")
.check(argv => {
if (!((argv.password && argv.keyfile) || argv.privKey || argv.mnemonic)) {
throw new Error(
"MISSING ARGS: Either user private key, keyfile+password or mnemonic must be provided."
);
} else return true;
});
};
module.exports = { withKeyArgs };