@@ -83,50 +83,51 @@ function handleError(
83
83
) : ( ...args : any [ ] ) => Promise < void > {
84
84
return async ( ...args : any [ ] ) => {
85
85
try {
86
- await f ( ...args ) ;
86
+ const option = args . pop ( ) ;
87
+ await f ( args , option ) ;
87
88
} catch ( err ) {
88
89
console . error ( err . toString ( ) ) ;
89
90
process . exit ( 1 ) ;
90
91
}
91
92
} ;
92
93
}
93
94
94
- async function listCommand ( option : ListOption ) {
95
+ async function listCommand ( args : any [ ] , option : ListOption ) {
95
96
const cckey = await CCKey . create ( ) ;
96
97
const accountType = parseAccountType ( option . parent . accountType ) ;
97
98
await listKeys ( cckey , accountType ) ;
98
99
}
99
100
100
- async function createCommand ( option : CreateOption ) {
101
+ async function createCommand ( args : any [ ] , option : CreateOption ) {
101
102
const cckey = await CCKey . create ( ) ;
102
103
const accountType = parseAccountType ( option . parent . accountType ) ;
103
104
const passphrase = parsePassphrase ( option . passphrase ) ;
104
105
await createKey ( cckey , accountType , passphrase ) ;
105
106
}
106
107
107
- async function deleteCommand ( option : DeleteOption ) {
108
+ async function deleteCommand ( args : any [ ] , option : DeleteOption ) {
108
109
const cckey = await CCKey . create ( ) ;
109
110
const accountType = parseAccountType ( option . parent . accountType ) ;
110
111
const address = parseAddress ( option . address ) ;
111
112
await deleteKey ( cckey , accountType , address ) ;
112
113
}
113
114
114
- async function importCommand ( path : string , option : ImportOption ) {
115
+ async function importCommand ( [ path ] : any [ ] , option : ImportOption ) {
115
116
const cckey = await CCKey . create ( ) ;
116
117
const accountType = parseAccountType ( option . parent . accountType ) ;
117
118
const passphrase = parsePassphrase ( option . passphrase ) ;
118
119
const contents = fs . readFileSync ( path , { encoding : "utf8" } ) ;
119
120
await importKey ( cckey , accountType , JSON . parse ( contents ) , passphrase ) ;
120
121
}
121
122
122
- async function importRawCommand ( privateKey : string , option : ImportOption ) {
123
+ async function importRawCommand ( [ privateKey ] : any [ ] , option : ImportOption ) {
123
124
const cckey = await CCKey . create ( ) ;
124
125
const accountType = parseAccountType ( option . parent . accountType ) ;
125
126
const passphrase = parsePassphrase ( option . passphrase ) ;
126
127
await importRawKey ( cckey , accountType , privateKey , passphrase ) ;
127
128
}
128
129
129
- async function exportCommand ( option : ExportOption ) {
130
+ async function exportCommand ( args : any [ ] , option : ExportOption ) {
130
131
const cckey = await CCKey . create ( ) ;
131
132
const accountType = parseAccountType ( option . parent . accountType ) ;
132
133
const address = parseAddress ( option . address ) ;
0 commit comments