Skip to content

Commit d31d8a7

Browse files
committed
Add --pretty option to export command
1 parent 3feff30 commit d31d8a7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ program
5959
.description("export the key")
6060
.option("-a, --address <address>", "address")
6161
.option("-p, --passphrase <passphrase>", "passphrase")
62+
.option("--pretty", "pretty-print the output")
6263
.action(handleError(exportCommand));
6364

6465
function handleError(
@@ -108,7 +109,10 @@ async function exportCommand(option: ExportOption) {
108109
const address = parseAddress(option.address);
109110
const passphrase = parsePassphrase(option.passphrase);
110111
const secret = await exportKey(cckey, accountType, address, passphrase);
111-
console.log(JSON.stringify(secret, null, 2));
112+
const res = option.pretty
113+
? JSON.stringify(secret, null, 2)
114+
: JSON.stringify(secret);
115+
console.log(res);
112116
}
113117

114118
program.on("--help", () => {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ export interface ExportOption {
3434
};
3535
address: string;
3636
passphrase: string;
37+
pretty: boolean;
3738
}

0 commit comments

Comments
 (0)