@burdenoff/bigconsole-cli 2026.802.1 → 2026.1110.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,186 +0,0 @@
1
- /**
2
- * Output utilities for CLI display.
3
- * Provides consistent formatting for both interactive and non-interactive modes.
4
- */
5
- /**
6
- * Check if the current terminal session is interactive (TTY).
7
- */
8
- export function isInteractive() {
9
- return Boolean(process.stdout.isTTY && process.stdin.isTTY);
10
- }
11
- /**
12
- * Determine the output format from command options, defaulting based on TTY.
13
- */
14
- export function getFormat(options) {
15
- if (options.format) {
16
- const f = options.format.toLowerCase();
17
- if (f === 'json' || f === 'table' || f === 'yaml')
18
- return f;
19
- }
20
- return isInteractive() ? 'table' : 'json';
21
- }
22
- /**
23
- * Print data as formatted JSON.
24
- */
25
- export function printJson(data) {
26
- console.log(JSON.stringify(data, null, 2));
27
- }
28
- /**
29
- * Print data as a simple ASCII table.
30
- */
31
- export function printTable(headers, rows) {
32
- if (headers.length === 0)
33
- return;
34
- const colWidths = headers.map((h, i) => {
35
- let max = h.length;
36
- for (const row of rows) {
37
- const cell = row[i] ?? '';
38
- if (cell.length > max)
39
- max = cell.length;
40
- }
41
- return Math.min(max, 50);
42
- });
43
- const separator = colWidths.map((w) => '-'.repeat(w + 2)).join('+');
44
- const formatRow = (cells) => cells.map((cell, i) => ` ${(cell ?? '').padEnd(colWidths[i] ?? 0)} `).join('|');
45
- console.log(formatRow(headers));
46
- console.log(separator);
47
- for (const row of rows) {
48
- console.log(formatRow(row));
49
- }
50
- }
51
- /**
52
- * Print data as YAML-like output (simple key-value).
53
- */
54
- export function printYaml(data) {
55
- if (typeof data !== 'object' || data === null) {
56
- console.log(String(data));
57
- return;
58
- }
59
- const lines = yamlSerialize(data, 0);
60
- console.log(lines);
61
- }
62
- function yamlSerialize(obj, indent) {
63
- const prefix = ' '.repeat(indent);
64
- const lines = [];
65
- for (const [key, value] of Object.entries(obj)) {
66
- if (value === null || value === undefined) {
67
- lines.push(`${prefix}${key}: null`);
68
- }
69
- else if (Array.isArray(value)) {
70
- lines.push(`${prefix}${key}:`);
71
- for (const item of value) {
72
- if (typeof item === 'object' && item !== null) {
73
- lines.push(`${prefix} -`);
74
- lines.push(yamlSerialize(item, indent + 2));
75
- }
76
- else {
77
- lines.push(`${prefix} - ${String(item)}`);
78
- }
79
- }
80
- }
81
- else if (typeof value === 'object') {
82
- lines.push(`${prefix}${key}:`);
83
- lines.push(yamlSerialize(value, indent + 1));
84
- }
85
- else {
86
- lines.push(`${prefix}${key}: ${String(value)}`);
87
- }
88
- }
89
- return lines.join('\n');
90
- }
91
- /**
92
- * Print a success message.
93
- */
94
- export function printSuccess(message) {
95
- console.log(`\u2713 ${message}`);
96
- }
97
- /**
98
- * Print an error message to stderr.
99
- */
100
- export function printError(message) {
101
- console.error(`\u2717 ${message}`);
102
- }
103
- /**
104
- * Print a warning message.
105
- */
106
- export function printWarning(message) {
107
- console.warn(`! ${message}`);
108
- }
109
- /**
110
- * Print an info message.
111
- */
112
- export function printInfo(message) {
113
- console.log(`\u2139 ${message}`);
114
- }
115
- /**
116
- * Format an ISO date string for display.
117
- */
118
- export function formatDate(date) {
119
- if (!date)
120
- return '-';
121
- try {
122
- return new Date(date).toLocaleString();
123
- }
124
- catch {
125
- return date;
126
- }
127
- }
128
- /**
129
- * Format a status string with emoji indicators.
130
- */
131
- export function formatStatus(status) {
132
- if (!status)
133
- return '-';
134
- const upper = status.toUpperCase();
135
- switch (upper) {
136
- case 'ACTIVE':
137
- case 'RUNNING':
138
- case 'HEALTHY':
139
- return `\u2713 ${status}`;
140
- case 'INACTIVE':
141
- case 'STOPPED':
142
- case 'PENDING':
143
- return `\u25CB ${status}`;
144
- case 'ERROR':
145
- return `\u2717 ${status}`;
146
- case 'ARCHIVED':
147
- return `\u2192 ${status}`;
148
- case 'STARTING':
149
- return `\u25B6 ${status}`;
150
- case 'TERMINATED':
151
- return `\u25A0 ${status}`;
152
- default:
153
- return status;
154
- }
155
- }
156
- /**
157
- * Output data in the specified format.
158
- */
159
- export function outputData(format, data, tableConfig) {
160
- switch (format) {
161
- case 'json':
162
- printJson(data);
163
- break;
164
- case 'yaml':
165
- printYaml(data);
166
- break;
167
- case 'table':
168
- if (tableConfig) {
169
- printTable(tableConfig.headers, tableConfig.rows);
170
- }
171
- else {
172
- printJson(data);
173
- }
174
- break;
175
- }
176
- }
177
- /**
178
- * Truncate a string to a maximum length, appending ellipsis if needed.
179
- */
180
- export function truncate(str, maxLen) {
181
- if (!str)
182
- return '-';
183
- if (str.length <= maxLen)
184
- return str;
185
- return str.substring(0, maxLen - 3) + '...';
186
- }