Skip to content

Commit 9221114

Browse files
Merge pull request #6 from chris-c-thomas/feat/tui
Enhance CLI UI and add multi-select Title options for downloads
2 parents 9e15faf + dedb71f commit 9221114

20 files changed

Lines changed: 862 additions & 130 deletions

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ tags
137137
# law2md operational outputs
138138
# -----------------------------------------------------------------------------
139139

140-
# Downloaded USC XML files (large, regenerable from OLRC)
141-
xml/
142-
143-
# Legacy location for downloaded XML (kept for backwards compatibility)
140+
# Downloaded source files (large, regenerable — e.g. downloads/usc/xml/)
144141
downloads/
142+
143+
# Legacy locations for downloaded XML (kept for backwards compatibility)
144+
xml/
145145
fixtures/xml/
146146

147147
# Converted Markdown output (regenerable from source XML)

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ dist
22
node_modules
33
pnpm-lock.yaml
44
*.md
5+
downloads
56
xml
67
fixtures/xml
78
docs/reference

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,42 @@ and this project adheres to [Conventional Commits](https://www.conventionalcommi
77

88
## [Unreleased]
99

10+
## [0.5.0]
11+
12+
### Added
13+
14+
#### Multi-Title Selection
15+
16+
- **`--titles <spec>` option** on both `download` and `convert` commands: supports single numbers (`29`), comma-separated lists (`1,3,8,11`), ranges (`1-5`), and mixed formats (`1-5,8,11`). Replaces the single-title `--title <n>` option on download. ([`3a29a8e`](../../commit/3a29a8e))
17+
- **`--input-dir <dir>` option** on `convert` command: specifies the directory containing USC XML files when using `--titles` (default: `./downloads/usc/xml`) ([`3a29a8e`](../../commit/3a29a8e))
18+
- **Multi-title convert output**: per-title summary tables with progress labels (`"Converting Title 1 (1/5)..."`) followed by an aggregate footer (`"Converted 5 titles (2,450 sections) in 3.2s"`) ([`3a29a8e`](../../commit/3a29a8e))
19+
- **`parseTitles()` utility** (`packages/cli/src/parse-titles.ts`): title spec parser with validation (1-54 range, ascending ranges, deduplication, sorting) and 23 unit tests ([`3a29a8e`](../../commit/3a29a8e))
20+
21+
### Changed
22+
23+
- **`convert` command**: `<input>` argument is now optional — use either a file path or `--titles` ([`3a29a8e`](../../commit/3a29a8e))
24+
- **`download` command**: `--title <n>` replaced by `--titles <spec>` ([`3a29a8e`](../../commit/3a29a8e))
25+
26+
---
27+
28+
## [0.4.1]
29+
30+
### Added
31+
32+
#### Terminal UI
33+
34+
- **Polished CLI output** (`packages/cli/src/ui.ts`): `chalk`, `ora`, and `cli-table3` for spinners, formatted summary blocks, and data tables in download and convert commands ([`a182dbe`](../../commit/a182dbe))
35+
36+
### Fixed
37+
38+
- **Default download/output locations**: adjusted default paths for `--output` on download and convert commands ([`9e15faf`](../../commit/9e15faf), [`5cbffd5`](../../commit/5cbffd5))
39+
40+
### Changed
41+
42+
- **Documentation cleanup**: renamed/reorganized docs, removed reference development docs, updated README with OLRC user guide details ([`52afb03`](../../commit/52afb03), [`0fc4a7e`](../../commit/0fc4a7e))
43+
44+
---
45+
1046
## [0.4.0] — Phase 4: Polish & Publish
1147

1248
### Added

CLAUDE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ law2md/
1212
│ ├── core/ # @law2md/core — XML parsing, AST, Markdown rendering, shared utilities
1313
│ ├── usc/ # @law2md/usc — U.S. Code-specific element handlers and downloader
1414
│ └── cli/ # law2md — CLI binary (the published npm package users install)
15-
├── xml/ # Full USC XML files (usc01.xml ... usc54.xml) — gitignored
15+
├── downloads/
16+
│ └── usc/
17+
│ └── xml/ # Full USC XML files (usc01.xml ... usc54.xml) — gitignored
1618
├── fixtures/
1719
│ ├── fragments/ # Small synthetic XML snippets for unit tests
1820
│ └── expected/ # Expected output snapshots for integration tests
@@ -66,7 +68,9 @@ pnpm turbo lint
6668
pnpm turbo dev
6769

6870
# Run the CLI locally during development
69-
node packages/cli/dist/index.js convert ./xml/usc01.xml -o ./test-output
71+
node packages/cli/dist/index.js convert ./downloads/usc/xml/usc01.xml -o ./test-output
72+
node packages/cli/dist/index.js convert --titles 1-5 -o ./test-output
73+
node packages/cli/dist/index.js download --titles 1
7074
```
7175

7276
## Code Conventions

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ pnpm turbo test --filter=law2md
4040

4141
```bash
4242
node packages/cli/dist/index.js convert path/to/usc01.xml -o ./output
43-
node packages/cli/dist/index.js download --title 1
43+
node packages/cli/dist/index.js download --titles 1 # saves to ./downloads/usc/xml/
44+
node packages/cli/dist/index.js convert --titles 1-5 # convert multiple titles
4445
```
4546

4647
### Formatting
@@ -100,7 +101,7 @@ Review the diff in `fixtures/expected/` to confirm only intended changes, then c
100101

101102
- `fixtures/fragments/` — Small synthetic XML snippets for unit tests (committed)
102103
- `fixtures/expected/` — Pinned expected output for snapshot tests (committed)
103-
- `xml/` — Full USC XML files (gitignored, download with `law2md download`)
104+
- `downloads/usc/xml/` — Full USC XML files (gitignored, download with `law2md download`)
104105

105106
## Submitting Changes
106107

README.md

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ pnpm turbo build
5858

5959
```bash
6060
# Download Title 1 (smallest title, good for testing)
61-
law2md download --title 1 -o ./xml
61+
law2md download --titles 1
6262

6363
# Convert to Markdown
64-
law2md convert ./xml/usc01.xml -o ./output
64+
law2md convert ./downloads/usc/xml/usc01.xml -o ./output
6565

66-
# Or do both in one shot
67-
law2md download --title 1 -o ./xml && law2md convert ./xml/usc01.xml -o ./output
66+
# Download and convert multiple titles at once
67+
law2md download --titles 1-5 && law2md convert --titles 1-5
6868
```
6969

7070
---
@@ -77,50 +77,69 @@ Fetch U.S. Code XML files directly from the Office of the Law Revision Counsel:
7777

7878
```bash
7979
# Download a single title
80-
law2md download --title 1 -o ./xml
80+
law2md download --titles 1
81+
82+
# Download multiple titles (range)
83+
law2md download --titles 1-5
84+
85+
# Download specific titles (mixed)
86+
law2md download --titles 1-5,8,11
8187

8288
# Download all 54 titles
83-
law2md download --all -o ./xml
89+
law2md download --all
8490

8591
# Use a specific release point
86-
law2md download --title 26 -o ./xml --release-point 119-73not60
92+
law2md download --titles 26 --release-point 119-73not60
8793
```
8894

8995
Or download manually from the [OLRC download page](https://uscode.house.gov/download/download.shtml).
9096

9197
### Convert
9298

9399
```bash
94-
# Section-level output (default)
95-
law2md convert ./xml/usc01.xml -o ./output
100+
# Convert a single XML file
101+
law2md convert ./downloads/usc/xml/usc01.xml -o ./output
102+
103+
# Convert by title number (uses default input directory)
104+
law2md convert --titles 1
105+
106+
# Convert multiple titles
107+
law2md convert --titles 1-5,8,11
108+
109+
# Convert with a custom input directory
110+
law2md convert --titles 1-5 -i ./my-xml-files
96111

97112
# Chapter-level output
98-
law2md convert ./xml/usc01.xml -o ./output -g chapter
113+
law2md convert ./downloads/usc/xml/usc01.xml -o ./output -g chapter
99114

100115
# Cross-reference links resolved to OLRC URLs
101-
law2md convert ./xml/usc05.xml -o ./output --link-style canonical
116+
law2md convert ./downloads/usc/xml/usc05.xml -o ./output --link-style canonical
102117

103118
# Include only amendment notes
104-
law2md convert ./xml/usc01.xml -o ./output --include-amendments
119+
law2md convert ./downloads/usc/xml/usc01.xml -o ./output --include-amendments
105120

106121
# Exclude all notes
107-
law2md convert ./xml/usc01.xml -o ./output --no-include-notes
122+
law2md convert ./downloads/usc/xml/usc01.xml -o ./output --no-include-notes
108123

109124
# Dry-run: preview stats without writing files
110-
law2md convert ./xml/usc42.xml -o ./output --dry-run
125+
law2md convert ./downloads/usc/xml/usc42.xml -o ./output --dry-run
111126
```
112127

113128
### CLI Reference
114129

115130
```bash
116-
law2md convert <input> [options]
131+
law2md convert [input] [options]
117132
```
118133

119134
```text
120135
Arguments:
121-
input Path to a USC XML file
136+
input Path to a USC XML file (optional if --titles is used)
122137
123138
Options:
139+
--titles <spec> Title(s) to convert: single (1), range (1-5),
140+
or mixed (1-5,8,11)
141+
-i, --input-dir <dir> Input directory for XML files
142+
(default: "./downloads/usc/xml")
124143
-o, --output <dir> Output directory (default: "./output")
125144
-g, --granularity <level> "section" or "chapter" (default: "section")
126145
--link-style <style> "plaintext", "canonical", or "relative"
@@ -137,9 +156,10 @@ Options:
137156
law2md download [options]
138157
139158
Options:
140-
--title <number> Download a single title (1-54)
159+
--titles <spec> Title(s) to download: single (1), range (1-5),
160+
or mixed (1-5,8,11)
141161
--all Download all 54 titles
142-
-o, --output <dir> Output directory (default: "./xml")
162+
-o, --output <dir> Output directory (default: "./downloads/usc/xml")
143163
--release-point <point> OLRC release point (default: current)
144164
-h, --help Display help
145165
```
@@ -189,7 +209,7 @@ positive_law: true
189209
currency: "119-73"
190210
last_updated: "2025-12-03"
191211
format_version: "1.0.0"
192-
generator: "law2md@0.4.0"
212+
generator: "law2md@0.5.0"
193213
source_credit: "(Added Pub. L. 104-199, § 3(a), Sept. 21, 1996, ...)"
194214
---
195215
```

docs/output-format.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ positive_law: true # Boolean
9999
currency: "119-73" # Release point identifier
100100
last_updated: "2025-12-03" # ISO date from XML generation
101101
format_version: "1.0.0" # Output format version
102-
generator: "law2md@0.4.0" # Generator version
102+
generator: "law2md@0.5.0" # Generator version
103103

104104
# Optional
105105
source_credit: "(July 30, 1947, ...)" # Full source credit text (included by default)
@@ -212,7 +212,7 @@ Complex tables (with colspan, rowspan, or nested content) render as fenced HTML:
212212
```json
213213
{
214214
"format_version": "1.0.0",
215-
"generator": "law2md@0.4.0",
215+
"generator": "law2md@0.5.0",
216216
"generated_at": "2025-12-03T12:00:00.000Z",
217217
"identifier": "/us/usc/t1",
218218
"title_number": 1,

packages/cli/CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# law2md
22

3+
## 0.5.0
4+
5+
### Minor Changes
6+
7+
- 3a29a8e: Add `--titles` multi-select option to download and convert commands. Supports ranges (`1-5`), comma-separated lists
8+
9+
### Patch Changes
10+
11+
- Updated dependencies [3a29a8e]
12+
- @law2md/core@0.5.0
13+
- @law2md/usc@0.5.0
14+
15+
## 0.4.1
16+
17+
### Patch Changes
18+
19+
- Add chalk, ora, and cli-table3 for polished terminal output with spinners and formatted
20+
- Updated dependencies
21+
- @law2md/core@0.4.1
22+
- @law2md/usc@0.4.1
23+
324
## 0.4.0
425

526
### Minor Changes

packages/cli/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "law2md",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"description": "Convert U.S. legislative XML (USLM) to structured Markdown for AI/RAG ingestion",
55
"type": "module",
66
"main": "./dist/index.js",
@@ -29,7 +29,10 @@
2929
"dependencies": {
3030
"@law2md/core": "workspace:*",
3131
"@law2md/usc": "workspace:*",
32+
"chalk": "^5.6.2",
33+
"cli-table3": "^0.6.5",
3234
"commander": "^13.1.0",
35+
"ora": "^8.2.0",
3336
"pino": "^9.6.0",
3437
"pino-pretty": "^13.0.0"
3538
},

0 commit comments

Comments
 (0)