@pablozaiden/terminatui 0.1.2 → 0.3.0-beta-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.
- package/AGENTS.md +43 -0
- package/CLAUDE.md +1 -0
- package/README.md +64 -43
- package/bun.lock +85 -0
- package/examples/tui-app/commands/config/app/get.ts +62 -0
- package/examples/tui-app/commands/config/app/index.ts +23 -0
- package/examples/tui-app/commands/config/app/set.ts +96 -0
- package/examples/tui-app/commands/config/index.ts +28 -0
- package/examples/tui-app/commands/config/user/get.ts +61 -0
- package/examples/tui-app/commands/config/user/index.ts +23 -0
- package/examples/tui-app/commands/config/user/set.ts +57 -0
- package/examples/tui-app/commands/greet.ts +14 -11
- package/examples/tui-app/commands/math.ts +6 -9
- package/examples/tui-app/commands/status.ts +24 -13
- package/examples/tui-app/index.ts +7 -3
- package/guides/01-hello-world.md +7 -2
- package/guides/02-adding-options.md +2 -2
- package/guides/03-multiple-commands.md +6 -8
- package/guides/04-subcommands.md +8 -8
- package/guides/05-interactive-tui.md +45 -30
- package/guides/06-config-validation.md +4 -12
- package/guides/07-async-cancellation.md +15 -69
- package/guides/08-complete-application.md +13 -179
- package/guides/README.md +7 -3
- package/package.json +4 -8
- package/src/__tests__/application.test.ts +87 -68
- package/src/__tests__/buildCliCommand.test.ts +99 -119
- package/src/__tests__/builtins.test.ts +27 -75
- package/src/__tests__/command.test.ts +100 -131
- package/src/__tests__/context.test.ts +1 -26
- package/src/__tests__/helpCore.test.ts +227 -0
- package/src/__tests__/parser.test.ts +98 -244
- package/src/__tests__/registry.test.ts +33 -160
- package/src/__tests__/schemaToFields.test.ts +75 -158
- package/src/builtins/help.ts +19 -4
- package/src/builtins/settings.ts +18 -32
- package/src/builtins/version.ts +4 -4
- package/src/cli/output/colors.ts +1 -1
- package/src/cli/parser.ts +26 -95
- package/src/core/application.ts +192 -110
- package/src/core/command.ts +26 -9
- package/src/core/context.ts +31 -20
- package/src/core/help.ts +24 -18
- package/src/core/knownCommands.ts +13 -0
- package/src/core/logger.ts +39 -42
- package/src/core/registry.ts +5 -12
- package/src/tui/TuiApplication.tsx +63 -120
- package/src/tui/TuiRoot.tsx +135 -0
- package/src/tui/adapters/factory.ts +19 -0
- package/src/tui/adapters/ink/InkRenderer.tsx +135 -0
- package/src/tui/adapters/ink/components/Button.tsx +12 -0
- package/src/tui/adapters/ink/components/Code.tsx +6 -0
- package/src/tui/adapters/ink/components/CodeHighlight.tsx +6 -0
- package/src/tui/adapters/ink/components/Container.tsx +5 -0
- package/src/tui/adapters/ink/components/Field.tsx +12 -0
- package/src/tui/adapters/ink/components/Label.tsx +24 -0
- package/src/tui/adapters/ink/components/MenuButton.tsx +12 -0
- package/src/tui/adapters/ink/components/MenuItem.tsx +17 -0
- package/src/tui/adapters/ink/components/Overlay.tsx +5 -0
- package/src/tui/adapters/ink/components/Panel.tsx +15 -0
- package/src/tui/adapters/ink/components/ScrollView.tsx +5 -0
- package/src/tui/adapters/ink/components/Select.tsx +44 -0
- package/src/tui/adapters/ink/components/Spacer.tsx +15 -0
- package/src/tui/adapters/ink/components/Spinner.tsx +5 -0
- package/src/tui/adapters/ink/components/TextInput.tsx +22 -0
- package/src/tui/adapters/ink/components/Value.tsx +7 -0
- package/src/tui/adapters/ink/keyboard.ts +97 -0
- package/src/tui/adapters/ink/utils.ts +16 -0
- package/src/tui/adapters/opentui/OpenTuiRenderer.tsx +115 -0
- package/src/tui/adapters/opentui/components/Button.tsx +13 -0
- package/src/tui/adapters/opentui/components/Code.tsx +12 -0
- package/src/tui/adapters/opentui/components/CodeHighlight.tsx +24 -0
- package/src/tui/adapters/opentui/components/Container.tsx +56 -0
- package/src/tui/adapters/opentui/components/Field.tsx +18 -0
- package/src/tui/adapters/opentui/components/Label.tsx +15 -0
- package/src/tui/adapters/opentui/components/MenuButton.tsx +14 -0
- package/src/tui/adapters/opentui/components/MenuItem.tsx +29 -0
- package/src/tui/adapters/opentui/components/Overlay.tsx +21 -0
- package/src/tui/adapters/opentui/components/Panel.tsx +78 -0
- package/src/tui/adapters/opentui/components/ScrollView.tsx +85 -0
- package/src/tui/adapters/opentui/components/Select.tsx +59 -0
- package/src/tui/adapters/opentui/components/Spacer.tsx +5 -0
- package/src/tui/adapters/opentui/components/Spinner.tsx +12 -0
- package/src/tui/adapters/opentui/components/TextInput.tsx +13 -0
- package/src/tui/adapters/opentui/components/Value.tsx +13 -0
- package/src/tui/{hooks → adapters/opentui/hooks}/useSpinner.ts +2 -11
- package/src/tui/adapters/opentui/keyboard.ts +61 -0
- package/src/tui/adapters/types.ts +70 -0
- package/src/tui/components/ActionButton.tsx +0 -36
- package/src/tui/components/CommandSelector.tsx +52 -92
- package/src/tui/components/ConfigForm.tsx +68 -42
- package/src/tui/components/FieldRow.tsx +0 -30
- package/src/tui/components/Header.tsx +14 -13
- package/src/tui/components/JsonHighlight.tsx +10 -17
- package/src/tui/components/ModalBase.tsx +38 -0
- package/src/tui/components/ResultsPanel.tsx +27 -36
- package/src/tui/components/StatusBar.tsx +24 -39
- package/src/tui/components/logColors.ts +12 -0
- package/src/tui/context/ClipboardContext.tsx +87 -0
- package/src/tui/context/ExecutorContext.tsx +139 -0
- package/src/tui/context/KeyboardContext.tsx +85 -71
- package/src/tui/context/LogsContext.tsx +35 -0
- package/src/tui/context/NavigationContext.tsx +194 -0
- package/src/tui/context/RendererContext.tsx +20 -0
- package/src/tui/context/TuiAppContext.tsx +58 -0
- package/src/tui/hooks/useActiveKeyHandler.ts +75 -0
- package/src/tui/hooks/useBackHandler.ts +34 -0
- package/src/tui/hooks/useClipboard.ts +40 -25
- package/src/tui/hooks/useClipboardProvider.ts +42 -0
- package/src/tui/hooks/useGlobalKeyHandler.ts +54 -0
- package/src/tui/modals/CliModal.tsx +82 -0
- package/src/tui/modals/EditorModal.tsx +207 -0
- package/src/tui/modals/LogsModal.tsx +98 -0
- package/src/tui/registry.ts +102 -0
- package/src/tui/screens/CommandSelectScreen.tsx +162 -0
- package/src/tui/screens/ConfigScreen.tsx +160 -0
- package/src/tui/screens/ErrorScreen.tsx +58 -0
- package/src/tui/screens/ResultsScreen.tsx +60 -0
- package/src/tui/screens/RunningScreen.tsx +72 -0
- package/src/tui/screens/ScreenBase.ts +6 -0
- package/src/tui/semantic/Button.tsx +7 -0
- package/src/tui/semantic/Code.tsx +7 -0
- package/src/tui/semantic/CodeHighlight.tsx +7 -0
- package/src/tui/semantic/Container.tsx +7 -0
- package/src/tui/semantic/Field.tsx +7 -0
- package/src/tui/semantic/Label.tsx +7 -0
- package/src/tui/semantic/MenuButton.tsx +7 -0
- package/src/tui/semantic/MenuItem.tsx +7 -0
- package/src/tui/semantic/Overlay.tsx +7 -0
- package/src/tui/semantic/Panel.tsx +7 -0
- package/src/tui/semantic/ScrollView.tsx +9 -0
- package/src/tui/semantic/Select.tsx +7 -0
- package/src/tui/semantic/Spacer.tsx +7 -0
- package/src/tui/semantic/Spinner.tsx +7 -0
- package/src/tui/semantic/TextInput.tsx +7 -0
- package/src/tui/semantic/Value.tsx +7 -0
- package/src/tui/semantic/types.ts +195 -0
- package/src/tui/theme.ts +25 -14
- package/src/tui/utils/buildCliCommand.ts +1 -0
- package/src/tui/utils/getEnumKeys.ts +3 -0
- package/src/tui/utils/parameterPersistence.ts +1 -0
- package/src/types/command.ts +0 -60
- package/examples/tui-app/commands/index.ts +0 -3
- package/src/__tests__/colors.test.ts +0 -127
- package/src/__tests__/commandClass.test.ts +0 -130
- package/src/__tests__/help.test.ts +0 -412
- package/src/__tests__/registryNew.test.ts +0 -160
- package/src/__tests__/table.test.ts +0 -146
- package/src/__tests__/tui.test.ts +0 -26
- package/src/builtins/index.ts +0 -4
- package/src/cli/help.ts +0 -174
- package/src/cli/index.ts +0 -3
- package/src/cli/output/index.ts +0 -2
- package/src/cli/output/table.ts +0 -141
- package/src/commands/help.ts +0 -50
- package/src/commands/index.ts +0 -1
- package/src/components/index.ts +0 -147
- package/src/core/index.ts +0 -15
- package/src/hooks/index.ts +0 -131
- package/src/index.ts +0 -137
- package/src/registry/commandRegistry.ts +0 -77
- package/src/registry/index.ts +0 -1
- package/src/tui/TuiApp.tsx +0 -582
- package/src/tui/app.ts +0 -29
- package/src/tui/components/CliModal.tsx +0 -81
- package/src/tui/components/EditorModal.tsx +0 -177
- package/src/tui/components/LogsPanel.tsx +0 -86
- package/src/tui/components/index.ts +0 -13
- package/src/tui/context/index.ts +0 -7
- package/src/tui/hooks/index.ts +0 -35
- package/src/tui/hooks/useKeyboardHandler.ts +0 -91
- package/src/tui/hooks/useLogStream.ts +0 -96
- package/src/tui/index.ts +0 -65
- package/src/tui/utils/index.ts +0 -13
- package/src/types/index.ts +0 -1
package/src/index.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
// Core - New OOP Architecture
|
|
2
|
-
export {
|
|
3
|
-
Application,
|
|
4
|
-
AppContext,
|
|
5
|
-
Command,
|
|
6
|
-
CommandRegistry,
|
|
7
|
-
ConfigValidationError,
|
|
8
|
-
AbortError,
|
|
9
|
-
Logger,
|
|
10
|
-
createLogger,
|
|
11
|
-
LogLevel,
|
|
12
|
-
generateCommandHelp,
|
|
13
|
-
generateAppHelp,
|
|
14
|
-
} from "./core/index.ts";
|
|
15
|
-
export type {
|
|
16
|
-
ApplicationConfig,
|
|
17
|
-
ApplicationHooks,
|
|
18
|
-
GlobalOptions,
|
|
19
|
-
AppConfig,
|
|
20
|
-
AnyCommand,
|
|
21
|
-
CommandExample,
|
|
22
|
-
CommandResult,
|
|
23
|
-
CommandExecutionContext,
|
|
24
|
-
ResolveResult,
|
|
25
|
-
LoggerConfig,
|
|
26
|
-
LogEvent,
|
|
27
|
-
HelpOptions,
|
|
28
|
-
} from "./core/index.ts";
|
|
29
|
-
|
|
30
|
-
// Execution Mode
|
|
31
|
-
export { ExecutionMode } from "./types/execution.ts";
|
|
32
|
-
|
|
33
|
-
// Built-in Commands (new)
|
|
34
|
-
export { HelpCommand, VersionCommand, SettingsCommand, formatVersion } from "./builtins/index.ts";
|
|
35
|
-
export type { VersionConfig } from "./builtins/index.ts";
|
|
36
|
-
|
|
37
|
-
// TUI Framework (new)
|
|
38
|
-
export {
|
|
39
|
-
TuiApp,
|
|
40
|
-
TuiApplication,
|
|
41
|
-
Theme,
|
|
42
|
-
KeyboardProvider,
|
|
43
|
-
KeyboardPriority,
|
|
44
|
-
useKeyboardHandler,
|
|
45
|
-
useClipboard,
|
|
46
|
-
useSpinner,
|
|
47
|
-
useConfigState,
|
|
48
|
-
useCommandExecutor,
|
|
49
|
-
useLogStream,
|
|
50
|
-
LogLevel as TuiLogLevel,
|
|
51
|
-
FieldRow,
|
|
52
|
-
ActionButton,
|
|
53
|
-
Header,
|
|
54
|
-
StatusBar,
|
|
55
|
-
LogsPanel,
|
|
56
|
-
ResultsPanel,
|
|
57
|
-
ConfigForm,
|
|
58
|
-
EditorModal,
|
|
59
|
-
CliModal,
|
|
60
|
-
CommandSelector,
|
|
61
|
-
JsonHighlight,
|
|
62
|
-
schemaToFieldConfigs,
|
|
63
|
-
groupFieldConfigs,
|
|
64
|
-
getFieldDisplayValue,
|
|
65
|
-
buildCliCommand,
|
|
66
|
-
} from "./tui/index.ts";
|
|
67
|
-
export type {
|
|
68
|
-
TuiApplicationConfig,
|
|
69
|
-
ThemeColors,
|
|
70
|
-
KeyboardEvent as TuiKeyboardEvent,
|
|
71
|
-
KeyboardHandler,
|
|
72
|
-
UseClipboardResult,
|
|
73
|
-
UseSpinnerResult,
|
|
74
|
-
UseConfigStateOptions,
|
|
75
|
-
UseConfigStateResult,
|
|
76
|
-
UseCommandExecutorResult,
|
|
77
|
-
LogEntry,
|
|
78
|
-
LogEvent as TuiLogEvent,
|
|
79
|
-
LogSource,
|
|
80
|
-
UseLogStreamResult,
|
|
81
|
-
FieldType,
|
|
82
|
-
FieldOption,
|
|
83
|
-
FieldConfig,
|
|
84
|
-
} from "./tui/index.ts";
|
|
85
|
-
|
|
86
|
-
// Types (legacy, for backwards compatibility)
|
|
87
|
-
export { defineCommand, defineTuiCommand } from "./types/command.ts";
|
|
88
|
-
export type {
|
|
89
|
-
Command as LegacyCommand,
|
|
90
|
-
TuiCommand,
|
|
91
|
-
OptionDef,
|
|
92
|
-
OptionSchema,
|
|
93
|
-
OptionValues,
|
|
94
|
-
CommandContext,
|
|
95
|
-
CommandExecutor,
|
|
96
|
-
} from "./types/command.ts";
|
|
97
|
-
|
|
98
|
-
// CLI Parser
|
|
99
|
-
export {
|
|
100
|
-
parseCliArgs,
|
|
101
|
-
extractCommandChain,
|
|
102
|
-
schemaToParseArgsOptions,
|
|
103
|
-
parseOptionValues,
|
|
104
|
-
validateOptions,
|
|
105
|
-
} from "./cli/parser.ts";
|
|
106
|
-
export type { ParseResult, ParseError } from "./cli/parser.ts";
|
|
107
|
-
|
|
108
|
-
// Registry (legacy)
|
|
109
|
-
export { createCommandRegistry } from "./registry/commandRegistry.ts";
|
|
110
|
-
export type { CommandRegistry as LegacyCommandRegistry } from "./registry/commandRegistry.ts";
|
|
111
|
-
|
|
112
|
-
// Built-in Commands (legacy)
|
|
113
|
-
export { createHelpCommand } from "./commands/help.ts";
|
|
114
|
-
|
|
115
|
-
// CLI Output
|
|
116
|
-
export { colors, supportsColors } from "./cli/output/colors.ts";
|
|
117
|
-
export { table, keyValueList, bulletList, numberedList } from "./cli/output/table.ts";
|
|
118
|
-
|
|
119
|
-
// Help Generation (legacy)
|
|
120
|
-
export {
|
|
121
|
-
generateHelp,
|
|
122
|
-
formatCommands,
|
|
123
|
-
formatOptions as formatOptionsLegacy,
|
|
124
|
-
formatUsage as formatUsageLegacy,
|
|
125
|
-
formatExamples as formatExamplesLegacy,
|
|
126
|
-
getCommandSummary,
|
|
127
|
-
} from "./cli/help.ts";
|
|
128
|
-
|
|
129
|
-
// TUI
|
|
130
|
-
export { createApp } from "./tui/app.ts";
|
|
131
|
-
export type { AppConfig as TuiAppConfig, AppState } from "./tui/app.ts";
|
|
132
|
-
|
|
133
|
-
// Components
|
|
134
|
-
export { Box, Text, Input, Select, Button, Modal, Spinner } from "./components/index.ts";
|
|
135
|
-
|
|
136
|
-
// Hooks
|
|
137
|
-
export { useCommand, useOptions, useNavigation, useModal, useAsync } from "./hooks/index.ts";
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { Command, OptionSchema } from "../types/command.ts";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Command registry for managing commands
|
|
5
|
-
*/
|
|
6
|
-
export interface CommandRegistry<T extends OptionSchema = OptionSchema> {
|
|
7
|
-
register(command: Command<T>): void;
|
|
8
|
-
get(name: string): Command<T> | undefined;
|
|
9
|
-
resolve(nameOrAlias: string): Command<T> | undefined;
|
|
10
|
-
has(nameOrAlias: string): boolean;
|
|
11
|
-
list(): Command<T>[];
|
|
12
|
-
getNames(): string[];
|
|
13
|
-
getCommandMap(): Record<string, Command<T>>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Create a command registry
|
|
18
|
-
*/
|
|
19
|
-
export function createCommandRegistry<
|
|
20
|
-
T extends OptionSchema = OptionSchema,
|
|
21
|
-
>(): CommandRegistry<T> {
|
|
22
|
-
const commands = new Map<string, Command<T>>();
|
|
23
|
-
const aliases = new Map<string, string>();
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
register(command: Command<T>): void {
|
|
27
|
-
if (commands.has(command.name)) {
|
|
28
|
-
throw new Error(`Command "${command.name}" is already registered`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
commands.set(command.name, command);
|
|
32
|
-
|
|
33
|
-
if (command.aliases) {
|
|
34
|
-
for (const alias of command.aliases) {
|
|
35
|
-
if (aliases.has(alias) || commands.has(alias)) {
|
|
36
|
-
throw new Error(`Alias "${alias}" conflicts with existing command or alias`);
|
|
37
|
-
}
|
|
38
|
-
aliases.set(alias, command.name);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
get(name: string): Command<T> | undefined {
|
|
44
|
-
return commands.get(name);
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
resolve(nameOrAlias: string): Command<T> | undefined {
|
|
48
|
-
// Try direct name first
|
|
49
|
-
const cmd = commands.get(nameOrAlias);
|
|
50
|
-
if (cmd) return cmd;
|
|
51
|
-
|
|
52
|
-
// Try alias
|
|
53
|
-
const resolvedName = aliases.get(nameOrAlias);
|
|
54
|
-
if (resolvedName) {
|
|
55
|
-
return commands.get(resolvedName);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return undefined;
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
has(nameOrAlias: string): boolean {
|
|
62
|
-
return commands.has(nameOrAlias) || aliases.has(nameOrAlias);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
list(): Command<T>[] {
|
|
66
|
-
return Array.from(commands.values());
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
getNames(): string[] {
|
|
70
|
-
return Array.from(commands.keys());
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
getCommandMap(): Record<string, Command<T>> {
|
|
74
|
-
return Object.fromEntries(commands);
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
}
|
package/src/registry/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./commandRegistry.ts";
|