@@ -8,13 +8,15 @@ import * as process from "process";
88
99import { createKey } from "./command/create" ;
1010import { deleteKey } from "./command/delete" ;
11+ import { exportKey } from "./command/export" ;
1112import { importKey } from "./command/import" ;
1213import { listKeys } from "./command/list" ;
1314import { CLIError , CLIErrorType } from "./error" ;
1415import {
1516 AccountType ,
1617 CreateOption ,
1718 DeleteOption ,
19+ ExportOption ,
1820 ImportOption ,
1921 ListOption
2022} from "./types" ;
@@ -52,6 +54,13 @@ program
5254 . option ( "-p, --passphrase <passphrase>" , "passphrase" )
5355 . action ( handleError ( importCommand ) ) ;
5456
57+ program
58+ . command ( "export" )
59+ . description ( "export the key" )
60+ . option ( "-a, --address <address>" , "address" )
61+ . option ( "-p, --passphrase <passphrase>" , "passphrase" )
62+ . action ( handleError ( exportCommand ) ) ;
63+
5564function handleError (
5665 f : ( ...args : any [ ] ) = > Promise < void >
5766) : ( ...args : any [ ] ) => Promise < void > {
@@ -93,6 +102,15 @@ async function importCommand(path: string, option: ImportOption) {
93102 await importKey ( cckey , accountType , JSON . parse ( contents ) , passphrase ) ;
94103}
95104
105+ async function exportCommand ( option : ExportOption ) {
106+ const cckey = await CCKey . create ( ) ;
107+ const accountType = parseAccountType ( option . parent . accountType ) ;
108+ const address = parseAddress ( option . address ) ;
109+ const passphrase = parsePassphrase ( option . passphrase ) ;
110+ const secret = await exportKey ( cckey , accountType , address , passphrase ) ;
111+ console . log ( JSON . stringify ( secret , null , 2 ) ) ;
112+ }
113+
96114program . on ( "--help" , ( ) => {
97115 console . log ( ` Examples:
98116
0 commit comments