Formatting
This commit is contained in:
@@ -27,7 +27,11 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
import { getDataDir, getMnemonicsDir, getWalletConfigPath } from "../../utils/paths.js";
|
||||
import {
|
||||
getDataDir,
|
||||
getMnemonicsDir,
|
||||
getWalletConfigPath,
|
||||
} from "../../utils/paths.js";
|
||||
import { loadMnemonic } from "../mnemonic.js";
|
||||
import { Storage } from "../../services/storage.js";
|
||||
import { COMMAND_TREE } from "./completions.js";
|
||||
@@ -56,7 +60,9 @@ async function getEngineModule() {
|
||||
*/
|
||||
function outputCompletions(items: readonly string[], prefix?: string): void {
|
||||
const filtered = prefix
|
||||
? items.filter((item) => item.toLowerCase().startsWith(prefix.toLowerCase()))
|
||||
? items.filter((item) =>
|
||||
item.toLowerCase().startsWith(prefix.toLowerCase()),
|
||||
)
|
||||
: items;
|
||||
|
||||
for (const item of filtered) {
|
||||
@@ -71,7 +77,9 @@ function outputCompletions(items: readonly string[], prefix?: string): void {
|
||||
function listMnemonics(prefix?: string): void {
|
||||
try {
|
||||
const mnemonicsDir = getMnemonicsDir();
|
||||
const files = readdirSync(mnemonicsDir).filter((f) => f.startsWith("mnemonic-"));
|
||||
const files = readdirSync(mnemonicsDir).filter((f) =>
|
||||
f.startsWith("mnemonic-"),
|
||||
);
|
||||
outputCompletions(files, prefix);
|
||||
} catch {
|
||||
// Silently fail - no completions available
|
||||
@@ -155,7 +163,13 @@ async function listTemplates(prefix?: string): Promise<void> {
|
||||
* Resolves a template by name or ID.
|
||||
*/
|
||||
async function resolveTemplate(
|
||||
engine: Awaited<ReturnType<Awaited<ReturnType<typeof getOfflineEngineModule>>["tryCreateOfflineEngine"]>>,
|
||||
engine: Awaited<
|
||||
ReturnType<
|
||||
Awaited<
|
||||
ReturnType<typeof getOfflineEngineModule>
|
||||
>["tryCreateOfflineEngine"]
|
||||
>
|
||||
>,
|
||||
templateQuery: string,
|
||||
) {
|
||||
if (!engine) return null;
|
||||
@@ -165,7 +179,9 @@ async function resolveTemplate(
|
||||
|
||||
// Try exact match on name or ID
|
||||
let template = templates.find(
|
||||
(t) => t.name === templateQuery || generateTemplateIdentifier(t) === templateQuery,
|
||||
(t) =>
|
||||
t.name === templateQuery ||
|
||||
generateTemplateIdentifier(t) === templateQuery,
|
||||
);
|
||||
|
||||
// Try partial match on name
|
||||
@@ -181,7 +197,10 @@ async function resolveTemplate(
|
||||
/**
|
||||
* Lists actions for a specific template.
|
||||
*/
|
||||
async function listActions(templateQuery: string, prefix?: string): Promise<void> {
|
||||
async function listActions(
|
||||
templateQuery: string,
|
||||
prefix?: string,
|
||||
): Promise<void> {
|
||||
const mnemonic = getCurrentMnemonic();
|
||||
if (!mnemonic) return;
|
||||
|
||||
@@ -210,7 +229,11 @@ async function listActions(templateQuery: string, prefix?: string): Promise<void
|
||||
* Lists fields (actions, transactions, outputs, etc.) for a specific template category.
|
||||
* Used for completing the 3rd argument of `template inspect <category> <template> <field>`.
|
||||
*/
|
||||
async function listFields(category: string, templateQuery: string, prefix?: string): Promise<void> {
|
||||
async function listFields(
|
||||
category: string,
|
||||
templateQuery: string,
|
||||
prefix?: string,
|
||||
): Promise<void> {
|
||||
const mnemonic = getCurrentMnemonic();
|
||||
if (!mnemonic) return;
|
||||
|
||||
@@ -300,7 +323,9 @@ async function listResources(prefix?: string): Promise<void> {
|
||||
|
||||
try {
|
||||
const utxos = await engine.listUnspentOutputsData();
|
||||
const outpoints = utxos.map((u) => `${u.outpointTransactionHash}:${u.outpointIndex}`);
|
||||
const outpoints = utxos.map(
|
||||
(u) => `${u.outpointTransactionHash}:${u.outpointIndex}`,
|
||||
);
|
||||
outputCompletions(outpoints, prefix);
|
||||
} finally {
|
||||
await engine.stop();
|
||||
|
||||
Reference in New Issue
Block a user