@ontrails/cli 1.0.0-beta.0 → 1.0.0-beta.2
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +19 -0
- package/README.md +36 -114
- package/package.json +3 -3
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @ontrails/cli
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix workspace dependency resolution in published packages. Now using bun publish
|
|
8
|
+
which correctly replaces workspace:^ with actual version numbers.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @ontrails/core@1.0.0-beta.2
|
|
11
|
+
|
|
12
|
+
## 1.0.0-beta.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fix two blocking bugs from real-world migration:
|
|
17
|
+
- Published packages now resolve correctly (workspace:^ instead of workspace:\*)
|
|
18
|
+
- Error forwarding works across different success types (Err no longer carries phantom T)
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @ontrails/core@1.0.0-beta.1
|
|
21
|
+
|
|
3
22
|
## 1.0.0-beta.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
# @ontrails/cli
|
|
2
2
|
|
|
3
|
-
CLI surface adapter
|
|
3
|
+
CLI surface adapter. One `blaze()` call turns a topo into a full CLI with flags, subcommands, help text, and error-mapped exit codes -- all derived from the trail contracts.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
bun add @ontrails/cli
|
|
9
|
-
# If using the /commander subpath:
|
|
10
|
-
bun add commander
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`commander` is an optional peer dependency -- only required if you use the `/commander` subpath. The main `@ontrails/cli` export is framework-agnostic.
|
|
14
|
-
|
|
15
|
-
## Quick Start
|
|
5
|
+
## Usage
|
|
16
6
|
|
|
17
7
|
```typescript
|
|
18
8
|
import { trail, topo, Result } from '@ontrails/core';
|
|
@@ -28,8 +18,6 @@ const app = topo('myapp', { greet });
|
|
|
28
18
|
blaze(app);
|
|
29
19
|
```
|
|
30
20
|
|
|
31
|
-
Pure trails can return `Result` directly. The CLI surface still runs the normalized awaitable implementation shape at execution time.
|
|
32
|
-
|
|
33
21
|
```bash
|
|
34
22
|
$ myapp greet --name World
|
|
35
23
|
Hello, World!
|
|
@@ -42,125 +30,59 @@ Options:
|
|
|
42
30
|
-h, --help display help for command
|
|
43
31
|
```
|
|
44
32
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### `blaze(app, options?)` -- Commander Adapter
|
|
48
|
-
|
|
49
|
-
The one-liner. Builds commands from the topo, adapts to Commander, parses `process.argv`.
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
import { blaze } from '@ontrails/cli/commander';
|
|
53
|
-
|
|
54
|
-
blaze(app, {
|
|
55
|
-
name: 'myapp',
|
|
56
|
-
version: '1.0.0',
|
|
57
|
-
onResult: async (ctx) => {
|
|
58
|
-
/* custom result handling */
|
|
59
|
-
},
|
|
60
|
-
layers: [myAuthLayer],
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### `buildCliCommands(app, options?)`
|
|
65
|
-
|
|
66
|
-
Framework-agnostic command builder. Produces `CliCommand[]` that any CLI framework can consume.
|
|
33
|
+
For more control, build the commands yourself:
|
|
67
34
|
|
|
68
35
|
```typescript
|
|
69
36
|
import { buildCliCommands } from '@ontrails/cli';
|
|
37
|
+
import { toCommander } from '@ontrails/cli/commander';
|
|
70
38
|
|
|
71
39
|
const commands = buildCliCommands(app);
|
|
72
|
-
|
|
40
|
+
const program = toCommander(commands, { name: 'myapp' });
|
|
41
|
+
program.parse();
|
|
73
42
|
```
|
|
74
43
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Flags are derived automatically from the trail's Zod input schema:
|
|
78
|
-
|
|
79
|
-
| Zod type | CLI flag | Notes |
|
|
80
|
-
| --------------------- | ------------------- | ----------------------------- |
|
|
81
|
-
| `z.string()` | `--name <value>` | Required string |
|
|
82
|
-
| `z.number()` | `--count <value>` | Required number |
|
|
83
|
-
| `z.boolean()` | `--verbose` | Boolean switch |
|
|
84
|
-
| `z.enum(["a", "b"])` | `--format <value>` | With choices |
|
|
85
|
-
| `z.array(z.string())` | `--tag <values...>` | Repeatable: `--tag a --tag b` |
|
|
86
|
-
| `z.optional(...)` | `--name [value]` | Optional |
|
|
87
|
-
| `z.default(...)` | `--name [value]` | With default value |
|
|
44
|
+
`buildCliCommands` returns a framework-agnostic `CliCommand[]`. Use `toCommander` for Commander, or write your own adapter.
|
|
88
45
|
|
|
89
|
-
|
|
46
|
+
## API
|
|
90
47
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `math.add` | `myapp math add` |
|
|
100
|
-
|
|
101
|
-
### Output Formatting
|
|
48
|
+
| Export | What it does |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `blaze(app, options?)` | One-liner: build commands, wire Commander, parse argv |
|
|
51
|
+
| `buildCliCommands(app)` | Framework-agnostic command builder, returns `CliCommand[]` |
|
|
52
|
+
| `toCommander(commands, options?)` | Adapt `CliCommand[]` to a Commander program |
|
|
53
|
+
| `deriveFlags(schema)` | Extract CLI flags from a Zod schema |
|
|
54
|
+
| `output(data, mode)` | Format output as JSON, JSONL, or text |
|
|
55
|
+
| `resolveOutputMode(options)` | Resolve output mode from flags and env vars |
|
|
102
56
|
|
|
103
|
-
|
|
104
|
-
import { output, resolveOutputMode } from '@ontrails/cli';
|
|
57
|
+
See the [API Reference](../../docs/api-reference.md) for the full list.
|
|
105
58
|
|
|
106
|
-
|
|
107
|
-
await output(items, 'jsonl'); // One JSON line per item
|
|
108
|
-
await output('Hello', 'text'); // Plain text
|
|
109
|
-
```
|
|
59
|
+
## Flag derivation
|
|
110
60
|
|
|
111
|
-
|
|
61
|
+
Flags come from the Zod schema automatically. No manual flag definitions.
|
|
112
62
|
|
|
113
|
-
|
|
63
|
+
| Zod type | CLI flag | Notes |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| `z.string()` | `--name <value>` | Required |
|
|
66
|
+
| `z.boolean()` | `--verbose` | Switch |
|
|
67
|
+
| `z.enum(["a","b"])` | `--format <value>` | With choices |
|
|
68
|
+
| `z.array(z.string())` | `--tag <values...>` | Repeatable |
|
|
69
|
+
| `z.optional(...)` | `--name [value]` | Optional |
|
|
114
70
|
|
|
115
|
-
-
|
|
116
|
-
- **`cwdPreset()`** -- `--cwd <path>`
|
|
117
|
-
- **`dryRunPreset()`** -- `--dry-run` (auto-added for destructive trails)
|
|
71
|
+
`camelCase` fields become `--kebab-case` flags. `.describe()` becomes help text.
|
|
118
72
|
|
|
119
|
-
|
|
73
|
+
## Subcommands
|
|
120
74
|
|
|
121
|
-
|
|
122
|
-
- **`dateShortcutsLayer`** -- Expands `"today"`, `"7d"`, `"30d"`, `"this-week"`, `"this-month"` into ISO date ranges.
|
|
75
|
+
Dotted trail IDs create subcommand groups: `entity.show` becomes `myapp entity show`.
|
|
123
76
|
|
|
124
|
-
|
|
77
|
+
## Layers
|
|
125
78
|
|
|
126
|
-
|
|
79
|
+
- **`autoIterateLayer`** -- adds `--all` for paginated trails, collects all pages
|
|
80
|
+
- **`dateShortcutsLayer`** -- expands `"today"`, `"7d"`, `"30d"` into ISO date ranges
|
|
127
81
|
|
|
128
|
-
|
|
129
|
-
import { buildCliCommands } from '@ontrails/cli';
|
|
130
|
-
import { toCommander } from '@ontrails/cli/commander';
|
|
82
|
+
## Installation
|
|
131
83
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
program.parse();
|
|
84
|
+
```bash
|
|
85
|
+
bun add @ontrails/cli commander
|
|
135
86
|
```
|
|
136
87
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
### Error Handling
|
|
140
|
-
|
|
141
|
-
Trail error categories map to exit codes automatically:
|
|
142
|
-
|
|
143
|
-
| Category | Exit code |
|
|
144
|
-
| ------------ | --------- |
|
|
145
|
-
| `validation` | 1 |
|
|
146
|
-
| `not_found` | 2 |
|
|
147
|
-
| `conflict` | 3 |
|
|
148
|
-
| `permission` | 4 |
|
|
149
|
-
| `timeout` | 5 |
|
|
150
|
-
| `rate_limit` | 6 |
|
|
151
|
-
| `network` | 7 |
|
|
152
|
-
| `internal` | 8 |
|
|
153
|
-
| `auth` | 9 |
|
|
154
|
-
| `cancelled` | 130 |
|
|
155
|
-
|
|
156
|
-
## Subpath Exports
|
|
157
|
-
|
|
158
|
-
| Export | Contents |
|
|
159
|
-
| --- | --- |
|
|
160
|
-
| `@ontrails/cli` | `buildCliCommands`, `deriveFlags`, `output`, `resolveOutputMode`, flag presets, layers, `CliCommand` types |
|
|
161
|
-
| `@ontrails/cli/commander` | `toCommander`, `blaze` (requires `commander` peer) |
|
|
162
|
-
|
|
163
|
-
## Further Reading
|
|
164
|
-
|
|
165
|
-
- [CLI Surface Guide](../../docs/surfaces/cli.md)
|
|
166
|
-
- [Getting Started](../../docs/getting-started.md)
|
|
88
|
+
`commander` is a peer dependency, required only for the `/commander` subpath.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ontrails/core": "
|
|
18
|
+
"@ontrails/core": "^1.0.0-beta.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"commander": "^14.0.3",
|
|
22
|
-
"zod": "
|
|
22
|
+
"zod": "^4.3.5"
|
|
23
23
|
},
|
|
24
24
|
"peerDependenciesMeta": {
|
|
25
25
|
"commander": {
|