Huge commit. Multiple fixes. Refactored commands. Invitations, resources, template inspection, mnemonic stuff, cli utils, pretty printing, remove unreserve on start, fix connectino requirement for invitations, format cashAddress to lockingBytecode on send, lots and lots of other stuff.
This commit is contained in:
48
src/cli/cli-utils.ts
Normal file
48
src/cli/cli-utils.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import util from "node:util";
|
||||
|
||||
/**
|
||||
* Text formatting utilities for the CLI.
|
||||
*
|
||||
* Uses ANSI escape codes to format text.
|
||||
*
|
||||
* AI Generated links:
|
||||
* @see https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
|
||||
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#Formatting
|
||||
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#Cursor_movement
|
||||
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#Screen_manipulation
|
||||
*/
|
||||
|
||||
const BOLD = "\x1b[1m";
|
||||
export const bold = (text: string) => `${BOLD}${text}${RESET}`;
|
||||
|
||||
const DIM = "\x1b[2m";
|
||||
export const dim = (text: string) => `${DIM}${text}${RESET}`;
|
||||
|
||||
const UNDERLINE = "\x1b[4m";
|
||||
export const underline = (text: string) => `${UNDERLINE}${text}${RESET}`;
|
||||
|
||||
const INVERSE = "\x1b[7m";
|
||||
export const inverse = (text: string) => `${INVERSE}${text}${RESET}`;
|
||||
|
||||
const HIDDEN = "\x1b[8m";
|
||||
export const hidden = (text: string) => `${HIDDEN}${text}${RESET}`;
|
||||
|
||||
const STRIKETHROUGH = "\x1b[9m";
|
||||
export const strikethrough = (text: string) => `${STRIKETHROUGH}${text}${RESET}`;
|
||||
|
||||
const RESET = "\x1b[0m";
|
||||
export const reset = (text: string) => `${RESET}${text}${RESET}`;
|
||||
|
||||
export const formatObject = (obj: unknown) => {
|
||||
return util.inspect(obj, {
|
||||
depth: null,
|
||||
colors: true,
|
||||
compact: false
|
||||
});
|
||||
};
|
||||
|
||||
export const objectPrint = (obj: unknown) => {
|
||||
console.log(formatObject(obj));
|
||||
};
|
||||
Reference in New Issue
Block a user