Skip to content

Commit 1cde902

Browse files
chore: refresh bun.lock and apply pickier --fix
1 parent 9ec8a47 commit 1cde902

7 files changed

Lines changed: 131 additions & 40 deletions

File tree

CONFIG_FEATURES.md

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Overview
44

55
zig-cli includes a powerful configuration system supporting three popular formats:
6+
67
- **TOML** - Simple, readable configuration format
78
- **JSONC** - JSON with Comments (also handles standard JSON)
89
- **JSON5** - JSON with extended syntax (more JavaScript-like)
@@ -14,18 +15,21 @@ zig-cli includes a powerful configuration system supporting three popular format
1415
Each format has its own strengths:
1516

1617
**TOML:**
18+
1719
- Simple, INI-like syntax
1820
- Great for human editing
1921
- Native support for nested tables
2022
- Comments with `#`
2123

2224
**JSONC:**
25+
2326
- JSON with `//` and `/* */` comments
2427
- Trailing commas allowed
2528
- Familiar to JavaScript developers
2629
- Works with standard JSON files too
2730

2831
**JSON5:**
32+
2933
- Unquoted object keys
3034
- Single and double quotes for strings
3135
- Trailing commas
@@ -44,7 +48,7 @@ const AppConfig = struct {
4448
host: []const u8,
4549
port: u16,
4650
},
47-
log_level: enum { debug, info, warn, @"error" } = .info,
51+
log*level: enum { debug, info, warn, @"error" } = .info,
4852
debug: bool = false,
4953
};
5054
@@ -69,6 +73,7 @@ defer config.deinit();
6973
```
7074

7175
Search locations (in order):
76+
7277
1. `./myapp.{toml,json5,jsonc,json}`
7378
2. `./.config/myapp.{toml,json5,jsonc,json}`
7479
3. `~/.config/myapp/myapp.{toml,json5,jsonc,json}`
@@ -80,19 +85,19 @@ First found file is loaded.
8085
For cases where you don't have a schema, use the raw `Config` type:
8186

8287
```zig
83-
var raw_config = cli.config.Config.init(allocator);
84-
defer raw_config.deinit();
88+
var raw*config = cli.config.Config.init(allocator);
89+
defer raw*config.deinit();
8590
86-
try raw_config.loadFromFile("config.toml", .auto);
91+
try raw*config.loadFromFile("config.toml", .auto);
8792
8893
// Typed getters with optional returns
89-
const name = raw_config.getString("name"); // ?[]const u8
90-
const port = raw_config.getInt("port"); // ?i64
91-
const debug = raw_config.getBool("debug"); // ?bool
92-
const timeout = raw_config.getFloat("timeout"); // ?f64
94+
const name = raw*config.getString("name"); // ?[]const u8
95+
const port = raw*config.getInt("port"); // ?i64
96+
const debug = raw*config.getBool("debug"); // ?bool
97+
const timeout = raw*config.getFloat("timeout"); // ?f64
9398
9499
// Raw value access for complex types
95-
const value = raw_config.get("database"); // ?*Value
100+
const value = raw*config.get("database"); // ?*Value
96101
```
97102

98103
### 5. Nested Configuration
@@ -127,18 +132,18 @@ timeout = 30
127132
Auto-detect based on file extension:
128133

129134
```zig
130-
try raw_config.loadFromFile("config.toml", .auto); // Detects TOML
131-
try raw_config.loadFromFile("config.json5", .auto); // Detects JSON5
132-
try raw_config.loadFromFile("config.jsonc", .auto); // Detects JSONC
133-
try raw_config.loadFromFile("config.json", .auto); // Treats as JSONC
135+
try raw*config.loadFromFile("config.toml", .auto); // Detects TOML
136+
try raw*config.loadFromFile("config.json5", .auto); // Detects JSON5
137+
try raw*config.loadFromFile("config.jsonc", .auto); // Detects JSONC
138+
try raw*config.loadFromFile("config.json", .auto); // Treats as JSONC
134139
```
135140

136141
Or specify explicitly:
137142

138143
```zig
139-
try raw_config.loadFromFile("myfile", .toml);
140-
try raw_config.loadFromFile("myfile", .jsonc);
141-
try raw_config.loadFromFile("myfile", .json5);
144+
try raw*config.loadFromFile("myfile", .toml);
145+
try raw*config.loadFromFile("myfile", .jsonc);
146+
try raw*config.loadFromFile("myfile", .json5);
142147
```
143148

144149
## Implementation Details
@@ -173,7 +178,7 @@ Unified `Value` type across all formats:
173178

174179
```zig
175180
pub const Value = union(enum) {
176-
null_value: void,
181+
null*value: void,
177182
boolean: bool,
178183
integer: i64,
179184
float: f64,
@@ -195,7 +200,7 @@ pub const Config = struct {
195200
// Loading
196201
pub fn loadFromFile(path, format) !void
197202
pub fn loadFromString(content, format) !void
198-
pub fn discover(allocator, app_name) !Config
203+
pub fn discover(allocator, app*name) !Config
199204
200205
// Accessing
201206
pub fn get(key) ?*Value
@@ -217,7 +222,7 @@ The `ConfigLoader` provides the high-level typed API:
217222
// These are available via cli.config namespace:
218223
pub fn load(comptime T: type, allocator, path) !ConfigLoader(T)
219224
pub fn loadFromString(comptime T: type, allocator, content, format) !ConfigLoader(T)
220-
pub fn discover(comptime T: type, allocator, app_name) !ConfigLoader(T)
225+
pub fn discover(comptime T: type, allocator, app*name) !ConfigLoader(T)
221226
```
222227

223228
## Usage Examples
@@ -236,7 +241,7 @@ const ServerConfig = struct {
236241
237242
pub fn main() !void {
238243
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
239-
defer _ = gpa.deinit();
244+
defer * = gpa.deinit();
240245
const allocator = gpa.allocator();
241246
242247
// Load typed config
@@ -284,22 +289,22 @@ fn serverAction(ctx: *cli.BaseCommand.ParseContext) !void {
284289
### Untyped Config with Nested Values
285290

286291
```zig
287-
var raw_config = cli.config.Config.init(allocator);
288-
defer raw_config.deinit();
292+
var raw*config = cli.config.Config.init(allocator);
293+
defer raw*config.deinit();
289294
290-
try raw_config.loadFromFile("config.toml", .auto);
295+
try raw*config.loadFromFile("config.toml", .auto);
291296
292297
// Access nested database config
293-
if (raw_config.get("database")) |db_value| {
294-
if (db_value.* == .table) {
295-
const db_table = &db_value.table;
298+
if (raw*config.get("database")) |db*value| {
299+
if (db*value.* == .table) {
300+
const db*table = &db*value.table;
296301
297-
const host = if (db_table.get("host")) |h|
302+
const host = if (db*table.get("host")) |h|
298303
if (h == .string) h.string else "localhost"
299304
else
300305
"localhost";
301306
302-
const port = if (db_table.get("port")) |p|
307+
const port = if (db*table.get("port")) |p|
303308
if (p == .integer) p.integer else 5432
304309
else
305310
5432;
@@ -376,6 +381,7 @@ zig build run-config
376381
## Summary
377382

378383
The configuration system provides:
384+
379385
- **3 format parsers** with full feature support (TOML, JSONC, JSON5)
380386
- **Type-safe API** via `cli.config.load(T, ...)` for compile-time schema validation
381387
- **Untyped API** via `cli.config.Config` for dynamic config access

FEATURE_PARITY.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
55
## Implemented Features
66

77
### CLI Framework
8+
89
- [x] **Fluent Builder API** - Chainable methods for intuitive CLI construction
910
- [x] **Command System** - Full command routing with nested subcommands
1011
- [x] **Command Aliases** - Support for command shortcuts (e.g., `build`, `b`)
@@ -18,6 +19,7 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
1819
- [x] **Type-Safe Commands** - `cli.Command(T)` with compile-time validated struct-based options
1920

2021
### Interactive Prompts
22+
2123
- [x] **TextPrompt** - Text input with placeholder and validation
2224
- [x] **ConfirmPrompt** - Yes/No confirmation
2325
- [x] **SelectPrompt** - Single selection from list
@@ -30,6 +32,7 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
3032
- [x] **Message Prompts** - intro, outro, note, log, cancel
3133

3234
### Terminal & UI
35+
3336
- [x] **Terminal Detection** - Unicode/ASCII support detection
3437
- [x] **Color Support** - ANSI colors with NO_COLOR respect
3538
- [x] **Dimension Detection** - Terminal width/height via ioctl
@@ -43,11 +46,13 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
4346
- [x] **Keyboard Events** - Full keyboard handling (arrows, enter, backspace, etc.)
4447

4548
### State Management
49+
4650
- [x] **State Machine** - 5-state system (initial -> active <-> error -> submit/cancel)
4751
- [x] **Event System** - Event types for value, cursor, key, submit, cancel
4852
- [x] **State Transitions** - Validated state transitions
4953

5054
### Configuration
55+
5156
- [x] **TOML Parser** - Full TOML format support
5257
- [x] **JSONC Parser** - JSON with comments
5358
- [x] **JSON5 Parser** - Extended JSON syntax
@@ -56,6 +61,7 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
5661
- [x] **Format Auto-detection** - Based on file extension
5762

5863
### Architecture
64+
5965
- [x] **Memory Safety** - Explicit allocators, proper cleanup
6066
- [x] **Error Handling** - Zig error unions throughout
6167
- [x] **Cross-platform** - macOS, Linux support (Windows partial)
@@ -64,6 +70,7 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
6470
## Partially Implemented
6571

6672
### Terminal
73+
6774
- [~] **Windows Support** - Basic structure exists, needs full implementation
6875
- Terminal raw mode placeholder
6976
- Console API integration needed
@@ -72,6 +79,7 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
7279
## Not Yet Implemented (from clapp)
7380

7481
### Additional Prompt Types
82+
7583
- [ ] **DatePrompt** - Date/time selection
7684
- [ ] **AutocompletePrompt** - Text input with suggestions
7785
- [ ] **GroupMultiselectPrompt** - Grouped multi-selection
@@ -81,26 +89,31 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
8189
- [ ] **StreamPrompt** - Streaming output display
8290

8391
### UI Components
92+
8493
- [ ] **Tree Rendering** - Hierarchical tree display
8594

8695
### Advanced Features
96+
8797
- [ ] **Theme System** - Customizable color themes
8898
- [ ] **Lifecycle Hooks** - SIGINT, SIGTERM, error handlers
8999
- [ ] **Shell Completion** - Generate shell completions
90100
- [ ] **Async Iterables** - Stream support for async operations
91101

92102
### Testing Utilities
103+
93104
- [ ] **Mock Prompts** - Testing helpers for prompts
94105
- [ ] **Output Capture** - Capture and test CLI output
95106
- [ ] **File System Mocks** - Testing file operations
96107

97108
### Utilities
109+
98110
- [ ] **Vim Keybindings** - hjkl navigation support
99111
- [ ] **Markdown Processing** - Render markdown in terminal
100112

101113
## Feature Completion Stats
102114

103115
### Core Features (Critical)
116+
104117
- **CLI Framework**: 100%
105118
- **Basic Prompts**: 100% (text, confirm, select, multiselect, password)
106119
- **Advanced Prompts**: 100% (number, path, group, spinner)
@@ -109,12 +122,14 @@ This document tracks the feature parity between zig-cli and the clapp TypeScript
109122
- **Configuration**: 100% (TOML, JSONC, JSON5, typed loader, auto-discovery)
110123

111124
### Advanced Features
125+
112126
- **Style System**: 95% (colors, chaining, backgrounds - themes missing)
113127
- **CLI Advanced**: 100% (aliases, middleware, typed commands)
114128
- **Platform Support**: 80% (Unix fully supported, Windows partial)
115129

116130
### Overall Completion
117-
**Estimated: ~95% feature parity**
131+
132+
#### Estimated: ~95% feature parity
118133

119134
All commonly used features are fully implemented. The remaining items (tree rendering, specialized prompt types, shell completion) are lower-priority specialized features.
120135

FINAL_SUMMARY.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ A **comprehensive CLI library for Zig 0.16+** with extensive feature parity to p
1919
### 1. CLI Framework (100% Complete)
2020

2121
**Core:**
22+
2223
- Fluent Builder API
2324
- Command routing with nested subcommands
2425
- Command aliases
@@ -30,13 +31,15 @@ A **comprehensive CLI library for Zig 0.16+** with extensive feature parity to p
3031
- Middleware system (pre/post hooks, built-in: logging, timing, validation)
3132

3233
**Type-Safe Layer:**
34+
3335
- `cli.Command(T)` - auto-generates options from struct fields
3436
- `cli.Context(T)` - compile-time validated field access
3537
- `cli.Action(T)` - typed action function signatures
3638

3739
### 2. Interactive Prompts (10 Types)
3840

3941
**Basic:**
42+
4043
- TextPrompt - with validation & placeholders
4144
- ConfirmPrompt - Yes/No
4245
- SelectPrompt - Single choice
@@ -45,11 +48,13 @@ A **comprehensive CLI library for Zig 0.16+** with extensive feature parity to p
4548
- NumberPrompt - Integer/Float with min/max
4649

4750
**Advanced:**
51+
4852
- SpinnerPrompt - Animated loading
4953
- PathPrompt - File/directory with Tab autocomplete
5054
- GroupPrompt - Sequential prompts with shared state
5155

5256
**UI/Messages:**
57+
5358
- Message prompts (intro, outro, note, log, cancel)
5459
- ProgressBar - 4 styles, percentage, count
5560
- Box rendering - 4 border styles
@@ -58,6 +63,7 @@ A **comprehensive CLI library for Zig 0.16+** with extensive feature parity to p
5863
### 3. Styling & Terminal
5964

6065
**Styling:**
66+
6167
- ANSI colors (16 colors)
6268
- Text styles (bold, dim, italic, underline)
6369
- Style chaining - `style(text).red().bold().underline()`
@@ -66,6 +72,7 @@ A **comprehensive CLI library for Zig 0.16+** with extensive feature parity to p
6672
- Symbols library
6773

6874
**Terminal:**
75+
6976
- Raw mode handling
7077
- Cursor control (hide/show, save/restore)
7178
- Dimension detection (width/height)
@@ -76,11 +83,13 @@ A **comprehensive CLI library for Zig 0.16+** with extensive feature parity to p
7683
### 4. Configuration System (100% Complete)
7784

7885
**Formats:**
86+
7987
- TOML parser
8088
- JSONC parser (JSON with comments)
8189
- JSON5 parser (extended JSON)
8290

8391
**Features:**
92+
8493
- Type-safe loading via `cli.config.load(T, ...)`
8594
- Auto-discovery of config files
8695
- Untyped access via `cli.config.Config`
@@ -170,7 +179,7 @@ const GreetOptions = struct {
170179
verbose: bool = false,
171180
};
172181
173-
fn greet(ctx: *cli.Context(GreetOptions)) !void {
182+
fn greet(ctx: _cli.Context(GreetOptions)) !void {
174183
const name = ctx.get(.name); // Compile-time validated!
175184
std.debug.print("Hello, {s}!\n", .{name});
176185
}
@@ -233,7 +242,7 @@ var progress = prompt.ProgressBar.init(allocator, 100, "Processing");
233242
try progress.start();
234243
235244
for (0..100) |i| {
236-
_ = std.c.nanosleep(&.{ .sec = 0, .nsec = 50 * std.time.ns_per_ms }, null);
245+
_ = std.c.nanosleep(&.{ .sec = 0, .nsec = 50 _ std.time.ns_per_ms }, null);
237246
try progress.update(i + 1);
238247
}
239248
@@ -274,7 +283,7 @@ try table.render();
274283
| **Terminal** | yes | yes | 90% |
275284
| **Middleware** | yes | yes | 100% |
276285

277-
**Overall: ~95% feature parity**
286+
#### Overall: ~95% feature parity
278287

279288
### What's Still Missing (Low Priority)
280289

@@ -321,15 +330,17 @@ zig build run-showcase # Run the showcase
321330

322331
---
323332

324-
## Why zig-cli?
333+
## Why zig-cli
325334

326335
### vs TypeScript/JavaScript CLIs
336+
327337
- **10-100x smaller binaries**
328338
- **Instant startup** (no Node.js runtime)
329339
- **Type safety** at compile time
330340
- **No dependencies** to manage
331341

332342
### vs Other Zig CLI libs
343+
333344
- **Most feature-complete**
334345
- **Interactive prompts included**
335346
- **Configuration support built-in**

0 commit comments

Comments
 (0)