@flowscripter/dynamic-cli-framework 1.1.6 → 1.2.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/.github/workflows/release-bun-library.yml +1 -0
- package/README/core-commands.md +40 -0
- package/README/core-service-providers.md +198 -0
- package/README/development.md +60 -0
- package/README/implementation-details.md +474 -0
- package/README/key-concepts.md +751 -0
- package/README.md +12 -1413
- package/bun.lock +22 -18
- package/index.ts +97 -1
- package/package.json +8 -7
- package/src/api/BaseCLIFeatureOptions.ts +10 -0
- package/src/api/CLIConfig.ts +5 -0
- package/src/api/RunResult.ts +16 -0
- package/src/api/argument/Argument.ts +24 -0
- package/src/api/service/ServiceProvider.ts +3 -3
- package/src/api/service/core/ArgumentPrompterService.ts +10 -0
- package/src/api/service/core/AsciiBannerGeneratorService.ts +44 -7
- package/src/api/service/core/CompletionService.ts +36 -0
- package/src/api/service/core/DataDumpGeneratorService.ts +27 -0
- package/src/api/service/core/ImagePrinterService.ts +26 -0
- package/src/api/service/core/KeyValueService.ts +22 -5
- package/src/api/service/core/PrinterService.ts +127 -1
- package/src/api/service/core/PrompterService.ts +49 -0
- package/src/api/service/core/SecretService.ts +27 -0
- package/src/api/service/core/ShutdownService.ts +17 -1
- package/src/api/service/core/Table.ts +85 -0
- package/src/api/service/core/TableGeneratorService.ts +38 -0
- package/src/api/service/core/TreePrinterService.ts +11 -0
- package/src/cli/BaseCLI.ts +116 -44
- package/src/cli/DefaultRuntimeCLI.ts +10 -18
- package/src/command/CompletionCommand.ts +179 -0
- package/src/command/MultiCommandCliHelpCommand.ts +18 -2
- package/src/command/SingleCommandCliHelpCommand.ts +10 -1
- package/src/launcher.ts +16 -58
- package/src/runtime/command/CommandValidator.ts +3 -3
- package/src/runtime/runner.ts +102 -30
- package/src/runtime/scanner.ts +18 -15
- package/src/runtime/values/argumentValueValidation.ts +49 -5
- package/src/runtime/values/globalCommandValuePopulation.ts +1 -1
- package/src/runtime/values/subCommandValuePopulation.ts +9 -8
- package/src/service/argumentPrompter/ArgumentPrompterServiceProvider.ts +34 -0
- package/src/service/argumentPrompter/DefaultArgumentPrompterService.ts +330 -0
- package/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts +1 -1
- package/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.ts +254 -17
- package/src/service/banner/BannerServiceProvider.ts +2 -2
- package/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts +85 -0
- package/src/service/chiselAsciiBannerGenerator/chisel.flf.json +3 -0
- package/src/service/completion/CompletionServiceProvider.ts +212 -0
- package/src/service/completion/DefaultCompletionService.ts +364 -0
- package/src/service/completion/shell/ShellHandler.ts +16 -0
- package/src/service/completion/shell/bash.ts +47 -0
- package/src/service/completion/shell/fish.ts +43 -0
- package/src/service/completion/shell/powershell.ts +66 -0
- package/src/service/completion/shell/zsh.ts +50 -0
- package/src/service/configuration/ConfigurationServiceProvider.ts +138 -42
- package/src/service/configuration/DefaultKeyValueService.ts +53 -7
- package/src/service/configuration/DefaultSecretService.ts +85 -0
- package/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.ts +41 -0
- package/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.ts +80 -0
- package/src/service/imagePrinter/DefaultImagePrinterService.ts +23 -0
- package/src/service/imagePrinter/ImagePrinterServiceProvider.ts +32 -0
- package/src/service/prettyPrinter/PrettyPrinterServiceProvider.ts +1 -1
- package/src/service/printer/DefaultPrinterService.ts +147 -27
- package/src/service/printer/PrinterServiceProvider.ts +7 -7
- package/src/service/printer/command/NoHyperlinksCommand.ts +40 -0
- package/src/service/printer/terminal/Progress.ts +21 -4
- package/src/service/printer/terminal/Spinner.ts +32 -8
- package/src/service/printer/terminal/Theme.ts +1 -1
- package/src/service/prompter/DefaultPrompterService.ts +87 -0
- package/src/service/prompter/PrompterServiceProvider.ts +36 -0
- package/src/service/prompter/command/NoPromptCommand.ts +40 -0
- package/src/service/prompter/prompt/PromptContext.ts +47 -0
- package/src/service/prompter/prompt/promptAcknowledge.ts +28 -0
- package/src/service/prompter/prompt/promptMultiSelect.ts +99 -0
- package/src/service/prompter/prompt/promptOpenUrl.ts +97 -0
- package/src/service/prompter/prompt/promptSingleSelect.ts +102 -0
- package/src/service/prompter/prompt/promptText.ts +107 -0
- package/src/service/prompter/prompt/promptToggle.ts +28 -0
- package/src/service/shutdown/DefaultShutdownService.ts +13 -0
- package/src/service/shutdown/ShutdownServiceProvider.ts +28 -9
- package/src/service/shutdown/ShutdownState.ts +5 -0
- package/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.ts +1 -1
- package/src/service/tableGenerator/DefaultTableGeneratorService.ts +415 -0
- package/src/service/tableGenerator/TableGeneratorServiceProvider.ts +43 -0
- package/src/service/treePrinter/DefaultTreePrinterService.ts +49 -0
- package/src/service/treePrinter/TreePrinterServiceProvider.ts +40 -0
- package/src/terminal/Ansi.ts +27 -0
- package/src/terminal/ImageRenderer.ts +199 -0
- package/src/terminal/KeyReader.ts +23 -0
- package/src/terminal/PngDecoder.ts +143 -0
- package/src/{service/printer/terminal → terminal}/Styler.ts +3 -0
- package/src/{service/printer/terminal → terminal}/Terminal.ts +1 -0
- package/src/terminal/TtyKeyReader.ts +83 -0
- package/src/terminal/TtyStyler.ts +78 -0
- package/src/{service/printer/terminal → terminal}/TtyTerminal.ts +9 -1
- package/src/terminal/supportsHyperlinks.ts +110 -0
- package/src/util/configHelper.ts +2 -2
- package/src/util/envVarHelper.ts +2 -2
- package/src/util/helpHelper.ts +66 -122
- package/src/util/logger.ts +16 -14
- package/src/util/runnerHelper.ts +1 -1
- package/tests/cli/BaseCLI.test.ts +50 -54
- package/tests/command/CompletionCommand.test.ts +68 -0
- package/tests/command/UsageCommand.test.ts +3 -2
- package/tests/command/VersionCommand.test.ts +3 -2
- package/tests/fixtures/Context.ts +9 -2
- package/tests/fixtures/util.ts +1 -1
- package/tests/runtime/parser.test.ts +9 -7
- package/tests/runtime/registry/DefaultServiceProviderRegistry.test.ts +3 -3
- package/tests/runtime/values/argumentValueValidation.test.ts +193 -0
- package/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.ts +47 -0
- package/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.ts +754 -0
- package/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.ts +5 -4
- package/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.ts +163 -3
- package/tests/service/asciiBannerGenerator/__snapshots__/DefaultAsciiBannerGeneratorService.test.ts.snap +1 -1
- package/tests/service/banner/BannerServiceProvider.test.ts +8 -4
- package/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.ts +52 -0
- package/tests/service/completion/CompletionServiceProvider.test.ts +404 -0
- package/tests/service/completion/DefaultCompletionService.test.ts +278 -0
- package/tests/service/completion/shell/bash.test.ts +73 -0
- package/tests/service/completion/shell/fish.test.ts +62 -0
- package/tests/service/completion/shell/powershell.test.ts +59 -0
- package/tests/service/completion/shell/zsh.test.ts +60 -0
- package/tests/service/configuration/ConfigurationServiceProvider.test.ts +24 -12
- package/tests/service/configuration/DefaultKeyValueService.test.ts +118 -16
- package/tests/service/configuration/DefaultSecretService.test.ts +148 -0
- package/tests/service/configuration/command/ConfigCommand.test.ts +29 -0
- package/tests/service/configuration/command/DumpConfigCommand.test.ts +60 -0
- package/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.ts +57 -0
- package/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.ts +217 -0
- package/tests/service/imagePrinter/DefaultImagePrinterService.test.ts +96 -0
- package/tests/service/imagePrinter/ImagePrinterServiceProvider.test.ts +17 -0
- package/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.ts +2 -2
- package/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.ts +5 -4
- package/tests/service/printer/DefaultPrinterService.test.ts +233 -2
- package/tests/service/printer/PrinterServiceProvider.test.ts +6 -5
- package/tests/service/printer/command/DarkModeCommand.test.ts +83 -0
- package/tests/service/printer/command/LogLevelCommand.test.ts +7 -5
- package/tests/service/printer/command/NoColorCommand.test.ts +83 -0
- package/tests/service/printer/command/NoHyperlinksCommand.test.ts +89 -0
- package/tests/service/printer/terminal/Progress.test.ts +64 -4
- package/tests/service/printer/terminal/Spinner.test.ts +44 -3
- package/tests/service/prompter/DefaultPrompterService.test.ts +615 -0
- package/tests/service/prompter/PrompterServiceProvider.test.ts +47 -0
- package/tests/service/prompter/command/NoPromptCommand.test.ts +58 -0
- package/tests/service/shutdown/ShutdownServiceProvider.test.ts +4 -2
- package/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.ts +3 -2
- package/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.ts +5 -4
- package/tests/service/tableGenerator/DefaultTableGeneratorService.test.ts +363 -0
- package/tests/service/tableGenerator/TableGeneratorServiceProvider.test.ts +47 -0
- package/tests/service/treePrinter/DefaultTreePrinterService.test.ts +144 -0
- package/tests/service/treePrinter/TreePrinterServiceProvider.test.ts +55 -0
- package/tests/terminal/ImageRenderer.test.ts +161 -0
- package/tests/terminal/PngDecoder.test.ts +223 -0
- package/tests/terminal/supportsHyperlinks.test.ts +149 -0
- package/tests/util/configHelper.test.ts +4 -4
- package/tests/util/logger.test.ts +23 -1
- package/tsconfig.json +31 -0
- package/src/service/printer/terminal/Ansi.ts +0 -10
- package/src/service/printer/terminal/TtyStyler.ts +0 -39
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Core Commands
|
|
2
|
+
|
|
3
|
+
The core `Command` implementations provided with the framework are:
|
|
4
|
+
|
|
5
|
+
## `MultiCommandCliHelpGlobalCommand`
|
|
6
|
+
|
|
7
|
+
Implementation of multi-command CLI help. Some examples:
|
|
8
|
+
|
|
9
|
+
- `myCli --help`
|
|
10
|
+
- `myCli -h`
|
|
11
|
+
- `myCli --help <command>`
|
|
12
|
+
- `myCli -h <command>`
|
|
13
|
+
|
|
14
|
+
## `MultiCommandCliHelpSubCommand`
|
|
15
|
+
|
|
16
|
+
Implementation of multi-command CLI help. Some examples:
|
|
17
|
+
|
|
18
|
+
- `myCli help`
|
|
19
|
+
- `myCli help <command>`
|
|
20
|
+
|
|
21
|
+
## `SingleCommandCliHelpGlobalCommand`
|
|
22
|
+
|
|
23
|
+
Implementation of single (default) command CLI help. Some examples:
|
|
24
|
+
|
|
25
|
+
- `myCli --help`
|
|
26
|
+
- `myCli -h`
|
|
27
|
+
|
|
28
|
+
## `SingleCommandCliHelpSubCommand`
|
|
29
|
+
|
|
30
|
+
Implementation of single (default) command CLI help. An example:
|
|
31
|
+
|
|
32
|
+
- `myCli help`
|
|
33
|
+
|
|
34
|
+
## `UsageCommand`
|
|
35
|
+
|
|
36
|
+
Implementation which prints basic CLI usage instructions.
|
|
37
|
+
|
|
38
|
+
## `VersionCommand`
|
|
39
|
+
|
|
40
|
+
Implementation which prints the version of the CLI.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Core Service Providers
|
|
2
|
+
|
|
3
|
+
The core `ServiceProvider` implementations (and the service and `Command`
|
|
4
|
+
implementations they provide) built into the framework are:
|
|
5
|
+
|
|
6
|
+
## `AsciiBannerGeneratorServiceProvider`
|
|
7
|
+
|
|
8
|
+
Provides:
|
|
9
|
+
|
|
10
|
+
- `AsciiBannerGeneratorService` allowing messages to be rendered using ASCII
|
|
11
|
+
banner [FIGlet](http://www.figlet.org) fonts. The FIGlet "standard" font is
|
|
12
|
+
provided by default and other fonts can be added on demand by commands.
|
|
13
|
+
Supports color effects (fixed, gradient, rainbow) applied independently to the
|
|
14
|
+
message foreground, sub-message foreground and background in both horizontal
|
|
15
|
+
and vertical directions.
|
|
16
|
+
- A `ChiselFontAsciiBannerGeneratorService` variant is also provided with a
|
|
17
|
+
built-in "chisel" FIGlet font and support for ANSI color remapping via
|
|
18
|
+
`ChiselBannerColors`.
|
|
19
|
+
|
|
20
|
+
## `BannerServiceProvider`
|
|
21
|
+
|
|
22
|
+
On initialisation this uses the `PrinterService` to output the CLI name in ASCII
|
|
23
|
+
banner text together with the CLI description, version and optional sub-message
|
|
24
|
+
(from `CLIConfig.subMessage`).
|
|
25
|
+
|
|
26
|
+
Provides:
|
|
27
|
+
|
|
28
|
+
- `NoBannerCommand` allowing banner printing to be disabled via the argument
|
|
29
|
+
`--no-banner` or the env var `NO_BANNER`.
|
|
30
|
+
|
|
31
|
+
## `CompletionServiceProvider`
|
|
32
|
+
|
|
33
|
+
Provides:
|
|
34
|
+
|
|
35
|
+
- `CompletionService` allowing shell auto-completion support for Bash, Zsh,
|
|
36
|
+
Fish, and PowerShell. Completions are dynamic (callback-based) rather than
|
|
37
|
+
static scripts, so they reflect the current set of registered commands
|
|
38
|
+
including dynamically discovered plugins.
|
|
39
|
+
- `CompletionGroupCommand` (`completions`) with two sub-commands:
|
|
40
|
+
- `completions:integration` installs shell completion integration by adding a
|
|
41
|
+
bootstrap script to the shell configuration file (e.g. `~/.bashrc`,
|
|
42
|
+
`~/.zshrc`, `~/.config/fish/config.fish`, or the PowerShell profile). Takes
|
|
43
|
+
a required `shell` positional argument and an optional `--config-path`
|
|
44
|
+
option.
|
|
45
|
+
- `completions:complete` generates completions for shell integration. This is
|
|
46
|
+
invoked by the shell's completion mechanism and returns completions in the
|
|
47
|
+
format expected by that shell.
|
|
48
|
+
- On first run, if both `PrompterService` and `KeyValueService` are available,
|
|
49
|
+
prompts the user to enable auto-completion.
|
|
50
|
+
|
|
51
|
+
NOTE: This service is opt-in. Enable via `completionEnabled` flag on `BaseCLI`,
|
|
52
|
+
`DefaultRuntimeCLI`, or the launcher functions.
|
|
53
|
+
|
|
54
|
+
## `ConfigurationServiceProvider`
|
|
55
|
+
|
|
56
|
+
Provides:
|
|
57
|
+
|
|
58
|
+
- `KeyValueService` allowing the storage and retrieval of key value pairs scoped
|
|
59
|
+
to the current `Command` or service being executed. The values are persisted
|
|
60
|
+
to the CLI configuration file.
|
|
61
|
+
- `ConfigCommand` allowing the default location of the configuration file to be
|
|
62
|
+
overridden via the argument `--config` or the env var `CONFIG_LOCATION`.
|
|
63
|
+
- `DumpConfigCommand` a global command which dumps the full CLI configuration to
|
|
64
|
+
stdout via `--dump-config`.
|
|
65
|
+
|
|
66
|
+
## `DataDumpGeneratorServiceProvider`
|
|
67
|
+
|
|
68
|
+
Provides:
|
|
69
|
+
|
|
70
|
+
- `DataDumpGeneratorService` allowing rendering of binary data as a hex dump or
|
|
71
|
+
ASCII dump. Supports configurable bytes per group, groups per row, spacing
|
|
72
|
+
between groups, and byte-range-based color schemes for visual differentiation
|
|
73
|
+
of byte value ranges.
|
|
74
|
+
|
|
75
|
+
## `ImagePrinterServiceProvider`
|
|
76
|
+
|
|
77
|
+
Provides:
|
|
78
|
+
|
|
79
|
+
- `ImagePrinterService` allowing rendering of images and animated GIFs in the
|
|
80
|
+
terminal. Images are rendered from a `Uint8Array` buffer with configurable
|
|
81
|
+
width as a percentage of the terminal width. GIF detection is automatic based
|
|
82
|
+
on file magic bytes.
|
|
83
|
+
|
|
84
|
+
## `PrettyPrinterServiceProvider`
|
|
85
|
+
|
|
86
|
+
Provides:
|
|
87
|
+
|
|
88
|
+
- `PrettyPrinterService` allowing pretty printing of structured data and source
|
|
89
|
+
code. JSON pretty printing is provided by default and other data or language
|
|
90
|
+
formats can be added on demand by commands.
|
|
91
|
+
|
|
92
|
+
## `PrinterServiceProvider`
|
|
93
|
+
|
|
94
|
+
Provides:
|
|
95
|
+
|
|
96
|
+
- `DefaultPrinterService` allowing foreground and background color output to
|
|
97
|
+
stdout, stderr, management of log levels and widgets such as a spinner and
|
|
98
|
+
progress bars. Background colors include theme-based variants (primary,
|
|
99
|
+
secondary, emphasised, selected) and named colors (yellow, orange, red,
|
|
100
|
+
magenta, violet, blue, cyan, green) as well as arbitrary hex colors. Printing
|
|
101
|
+
hyperlinks is supported.
|
|
102
|
+
- `DarkModeCommand` which allows dark or light mode to be enabled via the
|
|
103
|
+
argument `--dark-mode` or the env var `DARK_MODE`.
|
|
104
|
+
- `NoColorCommand` which allows color output to be disabled via the argument
|
|
105
|
+
`--no-color` or the env var `NO_COLOR`.
|
|
106
|
+
- `NoHyperlinksCommand` which allows hyperlink output to be disabled via the
|
|
107
|
+
argument `--no-hyperlinks` or the env var `NO_HYPERLINKS`.
|
|
108
|
+
- `LogLevelCommand` which allows the log level to be set via the argument
|
|
109
|
+
`--log-level` or the env var `LOG_LEVEL`.
|
|
110
|
+
|
|
111
|
+
## `PrompterServiceProvider`
|
|
112
|
+
|
|
113
|
+
Provides:
|
|
114
|
+
|
|
115
|
+
- `PrompterService` allowing interactive user input via the terminal. Supports
|
|
116
|
+
five prompt types: single select (scrollable list), multi select (checkboxes),
|
|
117
|
+
acknowledge (Yes/No), toggle (True/False), and text entry (with masking for
|
|
118
|
+
secrets). Configurable via `PrompterServiceConfig` for prompt characters,
|
|
119
|
+
checkbox characters, list colors, and scroll window size.
|
|
120
|
+
- `NoPromptCommand` which allows interactive prompting to be disabled via the
|
|
121
|
+
argument `--no-prompt` or the env var `NO_PROMPT`.
|
|
122
|
+
|
|
123
|
+
## `ArgumentPrompterServiceProvider`
|
|
124
|
+
|
|
125
|
+
Provides:
|
|
126
|
+
|
|
127
|
+
- `ArgumentPrompterService` which automatically prompts the user for missing
|
|
128
|
+
mandatory arguments when all parse errors are of type `MISSING_VALUE`. Derives
|
|
129
|
+
the appropriate prompt type from the argument definition: boolean arguments
|
|
130
|
+
become toggle prompts, arguments with allowable values become single select
|
|
131
|
+
prompts, and other arguments become text entry prompts. Handles complex
|
|
132
|
+
options by prompting for each nested property and array/vararg arguments by
|
|
133
|
+
repeating prompts with an "add another?" confirmation.
|
|
134
|
+
|
|
135
|
+
NOTE: Both services are opt-in. Enable via `prompterEnabled` and
|
|
136
|
+
`argumentPrompterEnabled` flags on `BaseCLI`, `DefaultRuntimeCLI`, or the
|
|
137
|
+
launcher functions. `argumentPrompterEnabled` requires `prompterEnabled`.
|
|
138
|
+
|
|
139
|
+
## `ShutdownServiceProvider`
|
|
140
|
+
|
|
141
|
+
Provides:
|
|
142
|
+
|
|
143
|
+
- `ShutdownService` allowing registration of callbacks for CLI shutdown.
|
|
144
|
+
|
|
145
|
+
Handles SIGINT (Ctrl-C) and SIGTERM signals:
|
|
146
|
+
|
|
147
|
+
- **Normal mode** (default): A single SIGINT triggers graceful shutdown (running
|
|
148
|
+
all registered shutdown listeners) then exits with code 130.
|
|
149
|
+
- **Long-running mode**: Commands can opt in via `enterLongRunningMode()`. In
|
|
150
|
+
this mode, the first SIGINT sets a cooperative `isShutdownRequested` flag that
|
|
151
|
+
the command can poll. A third SIGINT forces graceful shutdown and exit.
|
|
152
|
+
- **SIGTERM**: Always triggers immediate graceful shutdown and exits with code
|
|
153
|
+
143.
|
|
154
|
+
|
|
155
|
+
Cooperative cancellation pattern which can be used in a long running command:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
shutdownService.enterLongRunningMode();
|
|
159
|
+
while (!shutdownService.isShutdownRequested) {
|
|
160
|
+
// do work
|
|
161
|
+
}
|
|
162
|
+
shutdownService.leaveLongRunningMode();
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## `SyntaxHighlighterServiceProvider`
|
|
166
|
+
|
|
167
|
+
Provides:
|
|
168
|
+
|
|
169
|
+
- `SyntaxHighlighterService` allowing ANSI based color highlighting of
|
|
170
|
+
structured data and source code. JSON highlighting is provided by default and
|
|
171
|
+
other data or language formats can be added on demand by commands.
|
|
172
|
+
|
|
173
|
+
Note that the `SyntaxHighlighterService` has no effect if the
|
|
174
|
+
`DefaultPrinterService` is configured to disable color output.
|
|
175
|
+
|
|
176
|
+
## `TableGeneratorServiceProvider`
|
|
177
|
+
|
|
178
|
+
Provides:
|
|
179
|
+
|
|
180
|
+
- `TableGeneratorService` allowing rendering of tabular data using Unicode
|
|
181
|
+
box-drawing characters. Tables are defined using a `Table` class with
|
|
182
|
+
configurable rows, columns, and cells. Supports column flex-weight layout (CSS
|
|
183
|
+
flex-grow/shrink semantics), per-column/row/cell alignment (left, center,
|
|
184
|
+
right), configurable border colors, cell padding, and automatic word-wrapping
|
|
185
|
+
of cell contents. String width measurement uses `Bun.stringWidth` for correct
|
|
186
|
+
handling of CJK characters and emoji.
|
|
187
|
+
|
|
188
|
+
NOTE: This service is automatically registered by `BaseCLI` with priority 70 and
|
|
189
|
+
is used internally for help text rendering with proper column wrapping.
|
|
190
|
+
|
|
191
|
+
## `TreePrinterServiceProvider`
|
|
192
|
+
|
|
193
|
+
Provides:
|
|
194
|
+
|
|
195
|
+
- `TreePrinterService` allowing rendering of tree structures using Unicode
|
|
196
|
+
box-drawing characters. Trees are defined using `TreeNode` objects with a
|
|
197
|
+
`label` and optional `children` (which can be nested `TreeNode` objects or
|
|
198
|
+
plain strings). Node labels are colored using the `PrinterService`.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
Install dependencies:
|
|
4
|
+
|
|
5
|
+
`bun install`
|
|
6
|
+
|
|
7
|
+
Test:
|
|
8
|
+
|
|
9
|
+
`bun test`
|
|
10
|
+
|
|
11
|
+
**NOTE**: The following tasks use Deno as it excels at these and Bun does not
|
|
12
|
+
currently provide such functionality:
|
|
13
|
+
|
|
14
|
+
Format:
|
|
15
|
+
|
|
16
|
+
`deno fmt`
|
|
17
|
+
|
|
18
|
+
Lint:
|
|
19
|
+
|
|
20
|
+
`deno lint index.ts src/ tests/`
|
|
21
|
+
|
|
22
|
+
Generate HTML API Documentation:
|
|
23
|
+
|
|
24
|
+
`deno doc --html --name=template-bun-library index.ts`
|
|
25
|
+
|
|
26
|
+
### Debug Logging
|
|
27
|
+
|
|
28
|
+
Internal framework logging can be enabled by setting the
|
|
29
|
+
`DYNAMIC_CLI_FRAMEWORK_DEBUG` environment variable.
|
|
30
|
+
|
|
31
|
+
The logging implementation will look for an object conforming to the `Logger`
|
|
32
|
+
interface and use it if found. If not found, a simple logging implementation
|
|
33
|
+
using the `console` object will be used.
|
|
34
|
+
|
|
35
|
+
### Command and Service Validation
|
|
36
|
+
|
|
37
|
+
By default, commands and services that are built into the CLI or provided by
|
|
38
|
+
already installed plugins are not validated as they are loaded. The only
|
|
39
|
+
validation that takes place is for commands or services provided by plugins
|
|
40
|
+
BEFORE they are installed.
|
|
41
|
+
|
|
42
|
+
When using `launcher.ts` runtime validation of all commands and services can be
|
|
43
|
+
forced by defining the `DYNAMIC_CLI_FRAMEWORK_VALIDATE_ALL` environment
|
|
44
|
+
variable.
|
|
45
|
+
|
|
46
|
+
Command validation includes:
|
|
47
|
+
|
|
48
|
+
- ensuring multiple commands in the CLI do not have duplicate names or short
|
|
49
|
+
aliases.
|
|
50
|
+
- command options for each command do not include duplicate names or short
|
|
51
|
+
aliases.
|
|
52
|
+
- default values for options have the type specified by the option.
|
|
53
|
+
- default values for options match an allowable value if specified by the
|
|
54
|
+
option.
|
|
55
|
+
- default array values for options are specified only for array options.
|
|
56
|
+
- command options for each command do not include duplicate names or short
|
|
57
|
+
aliases.
|
|
58
|
+
- only the last positional for a command is defined as a vararg.
|
|
59
|
+
- default values for complex options match the nested property hierarchy.
|
|
60
|
+
- paths to nested properties of complex options are unique.
|