cli-menu-kit 0.1.0

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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +716 -0
  3. package/dist/api.d.ts +158 -0
  4. package/dist/api.js +128 -0
  5. package/dist/components/display/headers.d.ts +32 -0
  6. package/dist/components/display/headers.js +84 -0
  7. package/dist/components/display/index.d.ts +8 -0
  8. package/dist/components/display/index.js +31 -0
  9. package/dist/components/display/messages.d.ts +41 -0
  10. package/dist/components/display/messages.js +90 -0
  11. package/dist/components/display/progress.d.ts +41 -0
  12. package/dist/components/display/progress.js +82 -0
  13. package/dist/components/display/summary.d.ts +33 -0
  14. package/dist/components/display/summary.js +82 -0
  15. package/dist/components/inputs/index.d.ts +8 -0
  16. package/dist/components/inputs/index.js +15 -0
  17. package/dist/components/inputs/language-input.d.ts +11 -0
  18. package/dist/components/inputs/language-input.js +104 -0
  19. package/dist/components/inputs/modify-field.d.ts +11 -0
  20. package/dist/components/inputs/modify-field.js +42 -0
  21. package/dist/components/inputs/number-input.d.ts +11 -0
  22. package/dist/components/inputs/number-input.js +143 -0
  23. package/dist/components/inputs/text-input.d.ts +11 -0
  24. package/dist/components/inputs/text-input.js +114 -0
  25. package/dist/components/menus/boolean-menu.d.ts +11 -0
  26. package/dist/components/menus/boolean-menu.js +169 -0
  27. package/dist/components/menus/checkbox-menu.d.ts +11 -0
  28. package/dist/components/menus/checkbox-menu.js +161 -0
  29. package/dist/components/menus/index.d.ts +7 -0
  30. package/dist/components/menus/index.js +13 -0
  31. package/dist/components/menus/radio-menu.d.ts +11 -0
  32. package/dist/components/menus/radio-menu.js +158 -0
  33. package/dist/components.d.ts +55 -0
  34. package/dist/components.js +166 -0
  35. package/dist/core/colors.d.ts +64 -0
  36. package/dist/core/colors.js +139 -0
  37. package/dist/core/keyboard.d.ts +124 -0
  38. package/dist/core/keyboard.js +185 -0
  39. package/dist/core/renderer.d.ts +74 -0
  40. package/dist/core/renderer.js +217 -0
  41. package/dist/core/terminal.d.ts +89 -0
  42. package/dist/core/terminal.js +170 -0
  43. package/dist/features/commands.d.ts +57 -0
  44. package/dist/features/commands.js +161 -0
  45. package/dist/features/wizard.d.ts +62 -0
  46. package/dist/features/wizard.js +112 -0
  47. package/dist/i18n/languages/en.d.ts +5 -0
  48. package/dist/i18n/languages/en.js +54 -0
  49. package/dist/i18n/languages/zh.d.ts +5 -0
  50. package/dist/i18n/languages/zh.js +54 -0
  51. package/dist/i18n/registry.d.ts +36 -0
  52. package/dist/i18n/registry.js +82 -0
  53. package/dist/i18n/types.d.ts +65 -0
  54. package/dist/i18n/types.js +5 -0
  55. package/dist/index.d.ts +27 -0
  56. package/dist/index.js +104 -0
  57. package/dist/input.d.ts +40 -0
  58. package/dist/input.js +211 -0
  59. package/dist/menu-core.d.ts +52 -0
  60. package/dist/menu-core.js +201 -0
  61. package/dist/menu-multi.d.ts +21 -0
  62. package/dist/menu-multi.js +119 -0
  63. package/dist/menu-single.d.ts +18 -0
  64. package/dist/menu-single.js +138 -0
  65. package/dist/menu.d.ts +66 -0
  66. package/dist/menu.js +78 -0
  67. package/dist/types/display.types.d.ts +57 -0
  68. package/dist/types/display.types.js +5 -0
  69. package/dist/types/input.types.d.ts +88 -0
  70. package/dist/types/input.types.js +5 -0
  71. package/dist/types/layout.types.d.ts +56 -0
  72. package/dist/types/layout.types.js +36 -0
  73. package/dist/types/menu.types.d.ts +85 -0
  74. package/dist/types/menu.types.js +5 -0
  75. package/dist/types.d.ts +49 -0
  76. package/dist/types.js +5 -0
  77. package/package.json +35 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Base rendering functions for CLI Menu Kit
3
+ * Provides utilities for rendering menu components
4
+ */
5
+ /**
6
+ * Render a blank line
7
+ * @param count - Number of blank lines (default: 1)
8
+ */
9
+ export declare function renderBlankLines(count?: number): void;
10
+ /**
11
+ * Render a header
12
+ * @param text - Header text
13
+ * @param color - Optional color
14
+ */
15
+ export declare function renderHeader(text: string, color?: string): void;
16
+ /**
17
+ * Render an option line
18
+ * @param text - Option text
19
+ * @param isSelected - Whether option is selected
20
+ * @param isHighlighted - Whether option is highlighted (cursor on it)
21
+ * @param prefix - Optional prefix (e.g., "1. ", "A. ")
22
+ */
23
+ export declare function renderOption(text: string, isSelected: boolean, isHighlighted: boolean, prefix?: string): void;
24
+ /**
25
+ * Render input prompt
26
+ * @param prompt - Prompt text
27
+ * @param value - Current input value
28
+ * @param showCursor - Whether to show cursor
29
+ */
30
+ export declare function renderInputPrompt(prompt: string, value: string, showCursor?: boolean): void;
31
+ /**
32
+ * Render hints
33
+ * @param hints - Array of hint strings
34
+ */
35
+ export declare function renderHints(hints: string[]): void;
36
+ /**
37
+ * Render a separator line
38
+ * @param char - Character to use for separator
39
+ * @param width - Width of separator (default: terminal width)
40
+ */
41
+ export declare function renderSeparator(char?: string, width?: number): void;
42
+ /**
43
+ * Render a message with icon
44
+ * @param type - Message type (success, error, warning, info, question)
45
+ * @param message - Message text
46
+ */
47
+ export declare function renderMessage(type: 'success' | 'error' | 'warning' | 'info' | 'question', message: string): void;
48
+ /**
49
+ * Render progress indicator
50
+ * @param steps - Array of step names
51
+ * @param currentStep - Index of current step
52
+ */
53
+ export declare function renderProgress(steps: string[], currentStep: number): void;
54
+ /**
55
+ * Render a box with content
56
+ * @param content - Array of content lines
57
+ * @param title - Optional title
58
+ * @param width - Box width (default: auto)
59
+ */
60
+ export declare function renderBox(content: string[], title?: string, width?: number): void;
61
+ /**
62
+ * Count lines in rendered output
63
+ * @param text - Text to count lines in
64
+ * @returns Number of lines
65
+ */
66
+ export declare function countLines(text: string): number;
67
+ /**
68
+ * Pad text to width
69
+ * @param text - Text to pad
70
+ * @param width - Target width
71
+ * @param align - Alignment (left, center, right)
72
+ * @returns Padded text
73
+ */
74
+ export declare function padText(text: string, width: number, align?: 'left' | 'center' | 'right'): string;
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ /**
3
+ * Base rendering functions for CLI Menu Kit
4
+ * Provides utilities for rendering menu components
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.renderBlankLines = renderBlankLines;
8
+ exports.renderHeader = renderHeader;
9
+ exports.renderOption = renderOption;
10
+ exports.renderInputPrompt = renderInputPrompt;
11
+ exports.renderHints = renderHints;
12
+ exports.renderSeparator = renderSeparator;
13
+ exports.renderMessage = renderMessage;
14
+ exports.renderProgress = renderProgress;
15
+ exports.renderBox = renderBox;
16
+ exports.countLines = countLines;
17
+ exports.padText = padText;
18
+ const colors_js_1 = require("./colors.js");
19
+ const terminal_js_1 = require("./terminal.js");
20
+ /**
21
+ * Render a blank line
22
+ * @param count - Number of blank lines (default: 1)
23
+ */
24
+ function renderBlankLines(count = 1) {
25
+ for (let i = 0; i < count; i++) {
26
+ (0, terminal_js_1.writeLine)('');
27
+ }
28
+ }
29
+ /**
30
+ * Render a header
31
+ * @param text - Header text
32
+ * @param color - Optional color
33
+ */
34
+ function renderHeader(text, color) {
35
+ if (color) {
36
+ (0, terminal_js_1.writeLine)(`${color}${text}${colors_js_1.colors.reset}`);
37
+ }
38
+ else {
39
+ (0, terminal_js_1.writeLine)(text);
40
+ }
41
+ }
42
+ /**
43
+ * Render an option line
44
+ * @param text - Option text
45
+ * @param isSelected - Whether option is selected
46
+ * @param isHighlighted - Whether option is highlighted (cursor on it)
47
+ * @param prefix - Optional prefix (e.g., "1. ", "A. ")
48
+ */
49
+ function renderOption(text, isSelected, isHighlighted, prefix) {
50
+ let line = '';
51
+ // Add cursor indicator if highlighted
52
+ if (isHighlighted) {
53
+ line += `${colors_js_1.colors.cyan}❯ ${colors_js_1.colors.reset}`;
54
+ }
55
+ else {
56
+ line += ' ';
57
+ }
58
+ // Add checkbox for multi-select
59
+ if (isSelected !== undefined && typeof isSelected === 'boolean') {
60
+ line += isSelected ? `${colors_js_1.colors.green}◉${colors_js_1.colors.reset} ` : `${colors_js_1.colors.dim}○${colors_js_1.colors.reset} `;
61
+ }
62
+ // Add prefix if provided
63
+ if (prefix) {
64
+ line += `${colors_js_1.colors.dim}${prefix}${colors_js_1.colors.reset}`;
65
+ }
66
+ // Add option text
67
+ if (isHighlighted) {
68
+ line += `${colors_js_1.colors.cyan}${text}${colors_js_1.colors.reset}`;
69
+ }
70
+ else {
71
+ line += text;
72
+ }
73
+ (0, terminal_js_1.writeLine)(line);
74
+ }
75
+ /**
76
+ * Render input prompt
77
+ * @param prompt - Prompt text
78
+ * @param value - Current input value
79
+ * @param showCursor - Whether to show cursor
80
+ */
81
+ function renderInputPrompt(prompt, value, showCursor = false) {
82
+ let line = ` ${colors_js_1.colors.dim}${prompt}${colors_js_1.colors.reset} `;
83
+ if (value) {
84
+ line += `${colors_js_1.colors.cyan}${value}${colors_js_1.colors.reset}`;
85
+ }
86
+ if (showCursor) {
87
+ line += `${colors_js_1.colors.cyan}_${colors_js_1.colors.reset}`;
88
+ }
89
+ (0, terminal_js_1.writeLine)(line);
90
+ }
91
+ /**
92
+ * Render hints
93
+ * @param hints - Array of hint strings
94
+ */
95
+ function renderHints(hints) {
96
+ if (hints.length === 0)
97
+ return;
98
+ const hintLine = ` ${colors_js_1.colors.dim}${hints.join(' • ')}${colors_js_1.colors.reset}`;
99
+ (0, terminal_js_1.writeLine)(hintLine);
100
+ }
101
+ /**
102
+ * Render a separator line
103
+ * @param char - Character to use for separator
104
+ * @param width - Width of separator (default: terminal width)
105
+ */
106
+ function renderSeparator(char = '─', width) {
107
+ const termWidth = process.stdout.columns || 80;
108
+ const sepWidth = width || termWidth;
109
+ (0, terminal_js_1.writeLine)(char.repeat(sepWidth));
110
+ }
111
+ /**
112
+ * Render a message with icon
113
+ * @param type - Message type (success, error, warning, info, question)
114
+ * @param message - Message text
115
+ */
116
+ function renderMessage(type, message) {
117
+ let icon = '';
118
+ let color = colors_js_1.colors.reset;
119
+ switch (type) {
120
+ case 'success':
121
+ icon = '✓';
122
+ color = colors_js_1.colors.green;
123
+ break;
124
+ case 'error':
125
+ icon = '✗';
126
+ color = colors_js_1.colors.red;
127
+ break;
128
+ case 'warning':
129
+ icon = '⚠';
130
+ color = colors_js_1.colors.yellow;
131
+ break;
132
+ case 'info':
133
+ icon = 'ℹ';
134
+ color = colors_js_1.colors.blue;
135
+ break;
136
+ case 'question':
137
+ icon = '?';
138
+ color = colors_js_1.colors.yellow;
139
+ break;
140
+ }
141
+ (0, terminal_js_1.writeLine)(`${color}${icon}${colors_js_1.colors.reset} ${message}`);
142
+ }
143
+ /**
144
+ * Render progress indicator
145
+ * @param steps - Array of step names
146
+ * @param currentStep - Index of current step
147
+ */
148
+ function renderProgress(steps, currentStep) {
149
+ const parts = [];
150
+ steps.forEach((step, index) => {
151
+ if (index === currentStep) {
152
+ parts.push(`${colors_js_1.colors.cyan}${step}${colors_js_1.colors.reset}`);
153
+ }
154
+ else if (index < currentStep) {
155
+ parts.push(step);
156
+ }
157
+ else {
158
+ parts.push(`${colors_js_1.colors.dim}${step}${colors_js_1.colors.reset}`);
159
+ }
160
+ });
161
+ (0, terminal_js_1.writeLine)(` ${parts.join(` ${colors_js_1.colors.dim}→${colors_js_1.colors.reset} `)}`);
162
+ }
163
+ /**
164
+ * Render a box with content
165
+ * @param content - Array of content lines
166
+ * @param title - Optional title
167
+ * @param width - Box width (default: auto)
168
+ */
169
+ function renderBox(content, title, width) {
170
+ const termWidth = process.stdout.columns || 80;
171
+ const boxWidth = width || Math.min(termWidth - 4, 60);
172
+ // Top border
173
+ (0, terminal_js_1.writeLine)(`╭${'─'.repeat(boxWidth - 2)}╮`);
174
+ // Title if provided
175
+ if (title) {
176
+ const padding = Math.floor((boxWidth - title.length - 2) / 2);
177
+ (0, terminal_js_1.writeLine)(`│${' '.repeat(padding)}${title}${' '.repeat(boxWidth - padding - title.length - 2)}│`);
178
+ (0, terminal_js_1.writeLine)(`│${' '.repeat(boxWidth - 2)}│`);
179
+ }
180
+ // Content
181
+ content.forEach(line => {
182
+ const padding = boxWidth - line.length - 4;
183
+ (0, terminal_js_1.writeLine)(`│ ${line}${' '.repeat(padding)}│`);
184
+ });
185
+ // Bottom border
186
+ (0, terminal_js_1.writeLine)(`╰${'─'.repeat(boxWidth - 2)}╯`);
187
+ }
188
+ /**
189
+ * Count lines in rendered output
190
+ * @param text - Text to count lines in
191
+ * @returns Number of lines
192
+ */
193
+ function countLines(text) {
194
+ return text.split('\n').length;
195
+ }
196
+ /**
197
+ * Pad text to width
198
+ * @param text - Text to pad
199
+ * @param width - Target width
200
+ * @param align - Alignment (left, center, right)
201
+ * @returns Padded text
202
+ */
203
+ function padText(text, width, align = 'left') {
204
+ if (text.length >= width)
205
+ return text;
206
+ const padding = width - text.length;
207
+ switch (align) {
208
+ case 'left':
209
+ return text + ' '.repeat(padding);
210
+ case 'right':
211
+ return ' '.repeat(padding) + text;
212
+ case 'center':
213
+ const leftPad = Math.floor(padding / 2);
214
+ const rightPad = padding - leftPad;
215
+ return ' '.repeat(leftPad) + text + ' '.repeat(rightPad);
216
+ }
217
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Terminal control utilities for CLI Menu Kit
3
+ * Handles cursor movement, screen clearing, and terminal state
4
+ */
5
+ /**
6
+ * Terminal state tracking
7
+ */
8
+ export interface TerminalState {
9
+ stdin: NodeJS.ReadStream;
10
+ renderedLines: number;
11
+ isRawMode: boolean;
12
+ }
13
+ /**
14
+ * Initialize terminal for interactive mode
15
+ * @returns Terminal state object
16
+ */
17
+ export declare function initTerminal(): TerminalState;
18
+ /**
19
+ * Restore terminal to normal mode
20
+ * @param state - Terminal state
21
+ */
22
+ export declare function restoreTerminal(state: TerminalState): void;
23
+ /**
24
+ * Clear the current menu display
25
+ * @param state - Terminal state
26
+ */
27
+ export declare function clearMenu(state: TerminalState): void;
28
+ /**
29
+ * Clear a specific number of lines
30
+ * @param lines - Number of lines to clear
31
+ */
32
+ export declare function clearLines(lines: number): void;
33
+ /**
34
+ * Move cursor up by N lines
35
+ * @param lines - Number of lines to move up
36
+ */
37
+ export declare function moveCursorUp(lines: number): void;
38
+ /**
39
+ * Move cursor down by N lines
40
+ * @param lines - Number of lines to move down
41
+ */
42
+ export declare function moveCursorDown(lines: number): void;
43
+ /**
44
+ * Move cursor to beginning of line
45
+ */
46
+ export declare function moveCursorToLineStart(): void;
47
+ /**
48
+ * Clear current line
49
+ */
50
+ export declare function clearCurrentLine(): void;
51
+ /**
52
+ * Hide cursor
53
+ */
54
+ export declare function hideCursor(): void;
55
+ /**
56
+ * Show cursor
57
+ */
58
+ export declare function showCursor(): void;
59
+ /**
60
+ * Write text without newline
61
+ * @param text - Text to write
62
+ */
63
+ export declare function write(text: string): void;
64
+ /**
65
+ * Write text with newline
66
+ * @param text - Text to write
67
+ */
68
+ export declare function writeLine(text: string): void;
69
+ /**
70
+ * Get terminal width
71
+ * @returns Terminal width in columns
72
+ */
73
+ export declare function getTerminalWidth(): number;
74
+ /**
75
+ * Get terminal height
76
+ * @returns Terminal height in rows
77
+ */
78
+ export declare function getTerminalHeight(): number;
79
+ /**
80
+ * Clear entire screen
81
+ */
82
+ export declare function clearScreen(): void;
83
+ /**
84
+ * Exit with cleanup and goodbye message
85
+ * @param state - Terminal state
86
+ * @param onData - Data listener to remove
87
+ * @param showGoodbyeFn - Function to show goodbye message
88
+ */
89
+ export declare function exitWithGoodbye(state: TerminalState, onData: (key: string) => void, showGoodbyeFn: () => void): void;
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /**
3
+ * Terminal control utilities for CLI Menu Kit
4
+ * Handles cursor movement, screen clearing, and terminal state
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.initTerminal = initTerminal;
8
+ exports.restoreTerminal = restoreTerminal;
9
+ exports.clearMenu = clearMenu;
10
+ exports.clearLines = clearLines;
11
+ exports.moveCursorUp = moveCursorUp;
12
+ exports.moveCursorDown = moveCursorDown;
13
+ exports.moveCursorToLineStart = moveCursorToLineStart;
14
+ exports.clearCurrentLine = clearCurrentLine;
15
+ exports.hideCursor = hideCursor;
16
+ exports.showCursor = showCursor;
17
+ exports.write = write;
18
+ exports.writeLine = writeLine;
19
+ exports.getTerminalWidth = getTerminalWidth;
20
+ exports.getTerminalHeight = getTerminalHeight;
21
+ exports.clearScreen = clearScreen;
22
+ exports.exitWithGoodbye = exitWithGoodbye;
23
+ /**
24
+ * Initialize terminal for interactive mode
25
+ * @returns Terminal state object
26
+ */
27
+ function initTerminal() {
28
+ const stdin = process.stdin;
29
+ // Enable raw mode for character-by-character input
30
+ stdin.setRawMode(true);
31
+ stdin.resume();
32
+ stdin.setEncoding('utf8');
33
+ // Hide cursor
34
+ process.stdout.write('\x1b[?25l');
35
+ return {
36
+ stdin,
37
+ renderedLines: 0,
38
+ isRawMode: true
39
+ };
40
+ }
41
+ /**
42
+ * Restore terminal to normal mode
43
+ * @param state - Terminal state
44
+ */
45
+ function restoreTerminal(state) {
46
+ if (state.isRawMode) {
47
+ state.stdin.setRawMode(false);
48
+ state.isRawMode = false;
49
+ }
50
+ // Show cursor
51
+ process.stdout.write('\x1b[?25h');
52
+ state.stdin.pause();
53
+ }
54
+ /**
55
+ * Clear the current menu display
56
+ * @param state - Terminal state
57
+ */
58
+ function clearMenu(state) {
59
+ if (state.renderedLines > 0) {
60
+ // Move cursor up to the start of the menu
61
+ process.stdout.write(`\x1b[${state.renderedLines}A`);
62
+ // Clear from cursor to end of screen
63
+ process.stdout.write('\x1b[J');
64
+ state.renderedLines = 0;
65
+ }
66
+ }
67
+ /**
68
+ * Clear a specific number of lines
69
+ * @param lines - Number of lines to clear
70
+ */
71
+ function clearLines(lines) {
72
+ if (lines > 0) {
73
+ process.stdout.write(`\x1b[${lines}A`);
74
+ process.stdout.write('\x1b[J');
75
+ }
76
+ }
77
+ /**
78
+ * Move cursor up by N lines
79
+ * @param lines - Number of lines to move up
80
+ */
81
+ function moveCursorUp(lines) {
82
+ if (lines > 0) {
83
+ process.stdout.write(`\x1b[${lines}A`);
84
+ }
85
+ }
86
+ /**
87
+ * Move cursor down by N lines
88
+ * @param lines - Number of lines to move down
89
+ */
90
+ function moveCursorDown(lines) {
91
+ if (lines > 0) {
92
+ process.stdout.write(`\x1b[${lines}B`);
93
+ }
94
+ }
95
+ /**
96
+ * Move cursor to beginning of line
97
+ */
98
+ function moveCursorToLineStart() {
99
+ process.stdout.write('\r');
100
+ }
101
+ /**
102
+ * Clear current line
103
+ */
104
+ function clearCurrentLine() {
105
+ process.stdout.write('\r\x1b[K');
106
+ }
107
+ /**
108
+ * Hide cursor
109
+ */
110
+ function hideCursor() {
111
+ process.stdout.write('\x1b[?25l');
112
+ }
113
+ /**
114
+ * Show cursor
115
+ */
116
+ function showCursor() {
117
+ process.stdout.write('\x1b[?25h');
118
+ }
119
+ /**
120
+ * Write text without newline
121
+ * @param text - Text to write
122
+ */
123
+ function write(text) {
124
+ process.stdout.write(text);
125
+ }
126
+ /**
127
+ * Write text with newline
128
+ * @param text - Text to write
129
+ */
130
+ function writeLine(text) {
131
+ process.stdout.write(text + '\n');
132
+ }
133
+ /**
134
+ * Get terminal width
135
+ * @returns Terminal width in columns
136
+ */
137
+ function getTerminalWidth() {
138
+ return process.stdout.columns || 80;
139
+ }
140
+ /**
141
+ * Get terminal height
142
+ * @returns Terminal height in rows
143
+ */
144
+ function getTerminalHeight() {
145
+ return process.stdout.rows || 24;
146
+ }
147
+ /**
148
+ * Clear entire screen
149
+ */
150
+ function clearScreen() {
151
+ process.stdout.write('\x1b[2J\x1b[H');
152
+ }
153
+ /**
154
+ * Exit with cleanup and goodbye message
155
+ * @param state - Terminal state
156
+ * @param onData - Data listener to remove
157
+ * @param showGoodbyeFn - Function to show goodbye message
158
+ */
159
+ function exitWithGoodbye(state, onData, showGoodbyeFn) {
160
+ // Remove listener
161
+ state.stdin.removeListener('data', onData);
162
+ // Clear menu
163
+ clearMenu(state);
164
+ // Restore terminal
165
+ restoreTerminal(state);
166
+ // Show goodbye message
167
+ showGoodbyeFn();
168
+ // Exit
169
+ process.exit(0);
170
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Commands - Command handling system
3
+ * Handles special commands like /quit, /help, /clear, /back
4
+ */
5
+ /**
6
+ * Command handler function type
7
+ */
8
+ export type CommandHandler = (args?: string[]) => boolean | void;
9
+ /**
10
+ * Register a custom command
11
+ * @param command - Command name (without /)
12
+ * @param handler - Command handler function
13
+ * @param description - Command description
14
+ */
15
+ export declare function registerCommand(command: string, handler: CommandHandler, description: string): void;
16
+ /**
17
+ * Unregister a custom command
18
+ * @param command - Command name (without /)
19
+ */
20
+ export declare function unregisterCommand(command: string): void;
21
+ /**
22
+ * Clear all custom commands
23
+ */
24
+ export declare function clearCustomCommands(): void;
25
+ /**
26
+ * Check if input is a command
27
+ * @param input - Input string
28
+ * @returns True if input is a command
29
+ */
30
+ export declare function isCommand(input: string): boolean;
31
+ /**
32
+ * Parse command from input
33
+ * @param input - Input string
34
+ * @returns Command name and args, or null if not a command
35
+ */
36
+ export declare function parseCommand(input: string): {
37
+ command: string;
38
+ args: string[];
39
+ } | null;
40
+ /**
41
+ * Handle a command
42
+ * @param input - Input string
43
+ * @returns Command result (true = handled and should exit/go back, false = continue, undefined = not a command)
44
+ */
45
+ export declare function handleCommand(input: string): boolean | undefined;
46
+ /**
47
+ * Get all available commands
48
+ * @returns Array of command names with descriptions
49
+ */
50
+ export declare function getAvailableCommands(): Array<{
51
+ command: string;
52
+ description: string;
53
+ }>;
54
+ /**
55
+ * Show help for all commands
56
+ */
57
+ export declare function showCommandHelp(): void;