kanban-cli 0.3.0

Command-line interface for the kanban project management tool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# kanban-cli

Command-line interface for the kanban project management tool. Supports both an interactive TUI mode and a scriptable CLI mode for automation and integration.

## Installation

### From Source

```bash
cargo install --path .
```

### After Building

```bash
cargo build --release
# Binary located at: target/release/kanban
```

## Usage

### Interactive TUI Mode

```bash
# Launch interactive TUI
kanban

# Launch with specific file
kanban boards.json

# Launch with absolute path
kanban /path/to/myproject.json
```

### CLI Mode

```bash
# All CLI commands require a data file
kanban myproject.json board list
kanban myproject.json card create --board-id <ID> --column-id <ID> --title "New task"

# Or use KANBAN_FILE environment variable
export KANBAN_FILE=myproject.json
kanban board list
kanban card list --board-id <ID>
```

## CLI Commands

### Board Operations

```bash
# List all boards
kanban board list

# Create a new board
kanban board create --name "My Project"
kanban board create --name "My Project" --sprint-prefix "SPRINT" --card-prefix "TASK"

# Get board details
kanban board get <BOARD_ID>

# Update a board
kanban board update <BOARD_ID> --name "New Name"
kanban board update <BOARD_ID> --sprint-prefix "SP" --card-prefix "TSK"

# Delete a board
kanban board delete <BOARD_ID>
```

### Column Operations

```bash
# List columns for a board
kanban column list --board-id <BOARD_ID>

# Create a column
kanban column create --board-id <BOARD_ID> --name "In Progress"
kanban column create --board-id <BOARD_ID> --name "Review" --position 2

# Reorder a column (change position)
kanban column reorder <COLUMN_ID> --position 2

# Delete a column
kanban column delete <COLUMN_ID>
```

### Card Operations

```bash
# List cards (returns CardSummary — no description; use card get for full details)
kanban card list --board-id <BOARD_ID>
kanban card list --board-id <BOARD_ID> --column-id <COLUMN_ID>
kanban card list --board-id <BOARD_ID> --sprint-id <SPRINT_ID>

# Paginate results
kanban card list --board-id <BOARD_ID> --page 2 --page-size 20

# Create a card
kanban card create --board-id <BOARD_ID> --column-id <COLUMN_ID> --title "Implement feature"
kanban card create --board-id <BOARD_ID> --column-id <COLUMN_ID> --title "Bug fix" \
  --priority high --points 3 --description "Fix the login bug"

# Get card details
kanban card get <CARD_ID>

# Update a card
kanban card update <CARD_ID> --title "Updated title"
kanban card update <CARD_ID> --priority high --status done --points 5

# Move a card to another column
kanban card move <CARD_ID> --column-id <NEW_COLUMN_ID>
kanban card move <CARD_ID> --column-id <NEW_COLUMN_ID> --position 0

# List archived cards (also supports --page, --page-size)
kanban card list --archived

# Archive/restore/delete cards
kanban card archive <CARD_ID>
kanban card restore <CARD_ID>
kanban card delete <CARD_ID>  # permanently delete archived card

# Sprint assignment
kanban card assign-sprint <CARD_ID> --sprint-id <SPRINT_ID>
kanban card unassign-sprint <CARD_ID>

# Git integration
kanban card branch-name <CARD_ID>
kanban card git-checkout <CARD_ID>

# Bulk operations (comma-separated IDs)
kanban card bulk-archive --ids <ID1>,<ID2>,<ID3>
kanban card bulk-move --ids <ID1>,<ID2>,<ID3> --column-id <COLUMN_ID>
kanban card bulk-assign-sprint --ids <ID1>,<ID2>,<ID3> --sprint-id <SPRINT_ID>
```

### Sprint Operations

```bash
# List sprints for a board
kanban sprint list --board-id <BOARD_ID>

# Create a sprint
kanban sprint create --board-id <BOARD_ID>
kanban sprint create --board-id <BOARD_ID> --card-prefix "HOTFIX"

# Sprint lifecycle
kanban sprint activate <SPRINT_ID>
kanban sprint complete <SPRINT_ID>
kanban sprint cancel <SPRINT_ID>
```

### Export/Import

```bash
# Export a single board (outputs JSON to stdout)
kanban export --board-id <BOARD_ID>
kanban export --board-id <BOARD_ID> > board.json

# Export all boards
kanban export > all-boards.json

# Import boards from file
kanban import --file boards.json
```

### Shell Completions

```bash
# Generate completions for your shell
kanban completions bash > /etc/bash_completion.d/kanban
kanban completions zsh > ~/.zsh/completions/_kanban
kanban completions fish > ~/.config/fish/completions/kanban.fish
```

## Output Format

All CLI commands output JSON for easy parsing and scripting:

```json
{
  "success": true,
  "api_version": "0.2.0",
  "data": { ... }
}
```

`card list` and `card list --archived` return a paginated envelope. All list commands (board, column, sprint, card) use the same shape:

```json
{
  "success": true,
  "api_version": "0.2.0",
  "data": {
    "items": [ { "id": "...", "title": "...", "status": "Todo", ... } ],
    "total": 42,
    "page": 1,
    "page_size": 50,
    "total_pages": 1
  }
}
```

Card and archived-card items are summaries — `description` is excluded. Use `card get <ID>` for full card details.

```bash
# Pipe to jq for processing
kanban card list --board-id <ID> | jq '.data.items[] | .title'

# Check if operation succeeded
kanban board create --name "Test" | jq '.success'
```

## Environment Variables

**Data File:**

```bash
# Set default data file
export KANBAN_FILE=~/projects/kanban.json
kanban board list  # uses KANBAN_FILE
```

**Logging Configuration:**

```bash
# Set log level (trace, debug, info, warn, error)
RUST_LOG=debug kanban boards.json
RUST_LOG=info kanban

# Multiple crates
RUST_LOG=kanban_tui=debug,kanban_domain=info kanban
```

**Custom Editor (TUI mode):**

```bash
EDITOR=vim kanban boards.json
```

## File Format Specification

JSON structure for board files:

```json
{
  "boards": [
    {
      "board": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "My Project",
        "description": "Project description",
        "sprint_prefix": "sprint",
        "card_prefix": "task",
        "sprint_duration_days": 14,
        "task_sort_field": "Default",
        "task_sort_order": "Ascending"
      },
      "columns": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440001",
          "board_id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Todo",
          "position": 0,
          "wip_limit": null
        }
      ],
      "cards": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440002",
          "column_id": "550e8400-e29b-41d4-a716-446655440001",
          "title": "Implement feature",
          "description": null,
          "priority": "Medium",
          "status": "Todo",
          "points": 3,
          "position": 0,
          "card_number": 1,
          "assigned_prefix": null
        }
      ],
      "sprints": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440003",
          "board_id": "550e8400-e29b-41d4-a716-446655440000",
          "sprint_number": 1,
          "name_index": 0,
          "prefix": null,
          "status": "Planning"
        }
      ]
    }
  ]
}
```

## File Management

### Initialization

When launching with a file path:

1. **File exists**: Load boards from JSON
2. **File doesn't exist**: Create empty file with `{"boards": []}`
3. **No file argument**: Use temporary storage (lost on exit)

### Auto-Save Behavior

- **Immediate save**: Changes are saved automatically after each action
- **In-memory only**: Without file argument, all data discarded on exit

## Logging and Diagnostics

### Structured Logging

The application uses `tracing` for structured logging:

```bash
# Debug level for development
RUST_LOG=debug kanban

# Info level for normal operation
RUST_LOG=info kanban

# Trace level for detailed diagnostics
RUST_LOG=trace kanban
```

### Log Levels

- `TRACE` - Extremely detailed internal state
- `DEBUG` - Debug information for troubleshooting
- `INFO` - Normal operational information
- `WARN` - Warning messages (unexpected but handled)
- `ERROR` - Error messages (application failures)

## Architecture

Entry point layer coordinating all workspace crates:

```
kanban-core (foundation)
    └── kanban-domain (domain logic)
            └── kanban-tui (TUI layer)
                    └── kanban-cli (entry point & file management)
```

### Responsibilities

- Argument parsing with clap
- File initialization and path handling
- Logging setup with tracing
- Tokio async runtime initialization
- TUI application launch and coordination
- Graceful shutdown handling

## Examples

### Launch with Logging

```bash
# Start with debug logging
RUST_LOG=debug kanban myproject.json

# Filter by crate
RUST_LOG=kanban_domain=info,kanban_tui=debug kanban
```

### File Operations

```bash
# Create new file if doesn't exist
kanban new_project.json
# → Creates new_project.json with empty boards array

# Use existing file
kanban existing.json
# → Loads boards from existing.json

# No file (temporary, loses data on exit)
kanban
# → Uses in-memory storage only
```

## Dependencies

- `kanban-core` - Foundation types and traits
- `kanban-domain` - Domain models
- `kanban-tui` - Terminal UI
- `clap` - CLI argument parsing
- `tokio` - Async runtime
- `anyhow` - Error handling
- `tracing`, `tracing-subscriber` - Structured logging

## Binary Configuration

**Cargo.toml:**
```toml
[[bin]]
name = "kanban"
path = "src/main.rs"
```

Produces executable: `kanban` (named `kanban.exe` on Windows)

## License

Apache 2.0 - See [LICENSE.md](../../LICENSE.md) for details