Skip to content

Commit da36540

Browse files
majectykseo
authored andcommitted
Ignore unnecessary arguments
From now on, if a user executes `cckey list blahblah`, the "blahblah" is ignored.
1 parent 025232e commit da36540

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,50 +83,51 @@ function handleError(
8383
): (...args: any[]) => Promise<void> {
8484
return async (...args: any[]) => {
8585
try {
86-
await f(...args);
86+
const option = args.pop();
87+
await f(args, option);
8788
} catch (err) {
8889
console.error(err.toString());
8990
process.exit(1);
9091
}
9192
};
9293
}
9394

94-
async function listCommand(option: ListOption) {
95+
async function listCommand(args: any[], option: ListOption) {
9596
const cckey = await CCKey.create();
9697
const accountType = parseAccountType(option.parent.accountType);
9798
await listKeys(cckey, accountType);
9899
}
99100

100-
async function createCommand(option: CreateOption) {
101+
async function createCommand(args: any[], option: CreateOption) {
101102
const cckey = await CCKey.create();
102103
const accountType = parseAccountType(option.parent.accountType);
103104
const passphrase = parsePassphrase(option.passphrase);
104105
await createKey(cckey, accountType, passphrase);
105106
}
106107

107-
async function deleteCommand(option: DeleteOption) {
108+
async function deleteCommand(args: any[], option: DeleteOption) {
108109
const cckey = await CCKey.create();
109110
const accountType = parseAccountType(option.parent.accountType);
110111
const address = parseAddress(option.address);
111112
await deleteKey(cckey, accountType, address);
112113
}
113114

114-
async function importCommand(path: string, option: ImportOption) {
115+
async function importCommand([path]: any[], option: ImportOption) {
115116
const cckey = await CCKey.create();
116117
const accountType = parseAccountType(option.parent.accountType);
117118
const passphrase = parsePassphrase(option.passphrase);
118119
const contents = fs.readFileSync(path, { encoding: "utf8" });
119120
await importKey(cckey, accountType, JSON.parse(contents), passphrase);
120121
}
121122

122-
async function importRawCommand(privateKey: string, option: ImportOption) {
123+
async function importRawCommand([privateKey]: any[], option: ImportOption) {
123124
const cckey = await CCKey.create();
124125
const accountType = parseAccountType(option.parent.accountType);
125126
const passphrase = parsePassphrase(option.passphrase);
126127
await importRawKey(cckey, accountType, privateKey, passphrase);
127128
}
128129

129-
async function exportCommand(option: ExportOption) {
130+
async function exportCommand(args: any[], option: ExportOption) {
130131
const cckey = await CCKey.create();
131132
const accountType = parseAccountType(option.parent.accountType);
132133
const address = parseAddress(option.address);

0 commit comments

Comments
 (0)