Formatting

This commit is contained in:
2026-04-20 12:26:35 +00:00
parent 32c42cdc2d
commit dbfb2c68d2
32 changed files with 3557 additions and 1828 deletions

View File

@@ -1,5 +1,10 @@
import { bold, dim } from "../cli-utils.js";
import { listMnemonicFiles, createMnemonicFile, createMnemonicSeed, loadMnemonic } from "../mnemonic.js";
import {
listMnemonicFiles,
createMnemonicFile,
createMnemonicSeed,
loadMnemonic,
} from "../mnemonic.js";
import type { BaseCommandDependencies, CommandIO } from "./types.js";
import { CommandError } from "./types.js";
@@ -8,7 +13,7 @@ import { CommandError } from "./types.js";
*/
export const printMnemonicHelp = (io: CommandIO): void => {
io.out(
`
`
${bold("Usage:")} xo-cli mnemonic <sub-command>
${bold("Sub-commands:")}
@@ -18,7 +23,8 @@ ${bold("Sub-commands:")}
${bold("Options:")}
-o --output <output-filename> ${dim("Output filename for the mnemonic file")}
-h --help ${dim("Show this help message")}
`);
`,
);
};
/**
@@ -39,13 +45,20 @@ export const handleMnemonicCommand = async (
if (!subCommand) {
deps.io.verbose("No sub-command provided");
printMnemonicHelp(deps.io);
throw new CommandError("mnemonic.subcommand.missing", "No sub-command provided");
throw new CommandError(
"mnemonic.subcommand.missing",
"No sub-command provided",
);
}
switch (subCommand) {
case "create": {
const mnemonicSeed = createMnemonicSeed();
const savedAs = createMnemonicFile(mnemonicsDir, mnemonicSeed, options["output"]);
const savedAs = createMnemonicFile(
mnemonicsDir,
mnemonicSeed,
options["output"],
);
deps.io.out(`Mnemonic file created: ${savedAs} (${mnemonicSeed})`);
return { savedAs };
@@ -57,18 +70,25 @@ export const handleMnemonicCommand = async (
if (!mnemonicSeed) {
deps.io.verbose("No mnemonic seed provided");
printMnemonicHelp(deps.io);
throw new CommandError("mnemonic.import.seed_missing", "No mnemonic seed provided");
throw new CommandError(
"mnemonic.import.seed_missing",
"No mnemonic seed provided",
);
}
deps.io.verbose(`Mnemonic seed: ${mnemonicSeed}`);
const savedAs = createMnemonicFile(mnemonicsDir, mnemonicSeed, options["output"]);
const savedAs = createMnemonicFile(
mnemonicsDir,
mnemonicSeed,
options["output"],
);
deps.io.out(`Mnemonic file created: ${savedAs}`);
return { savedAs };
}
case "list": {
const mnemonicFiles = listMnemonicFiles(mnemonicsDir);
deps.io.out(mnemonicFiles.join('\n'));
deps.io.out(mnemonicFiles.join("\n"));
return { count: mnemonicFiles.length };
}
@@ -78,7 +98,10 @@ export const handleMnemonicCommand = async (
if (!mnemonicFile) {
deps.io.verbose("No mnemonic file provided");
printMnemonicHelp(deps.io);
throw new CommandError("mnemonic.expose.file_missing", "No mnemonic file provided");
throw new CommandError(
"mnemonic.expose.file_missing",
"No mnemonic file provided",
);
}
try {
@@ -96,6 +119,9 @@ export const handleMnemonicCommand = async (
default:
deps.io.err(`Unknown sub-command: ${subCommand}`);
printMnemonicHelp(deps.io);
throw new CommandError("mnemonic.subcommand.unknown", `Unknown sub-command: ${subCommand}`);
throw new CommandError(
"mnemonic.subcommand.unknown",
`Unknown sub-command: ${subCommand}`,
);
}
};