Skip to content

Commit ef82ece

Browse files
noahgiftclaude
andcommitted
Release v3.19.30 - Production-Ready ArgumentParser Support
🎉 **Major Feature**: Python CLI tools with argparse can now transpile to idiomatic Rust with clap derive macros! ## Features ### DEPYLER-0364: nargs & action Mapping (Commit f16b66a) **Phase 3: nargs Parameter Support** - nargs="+" → Vec<T> (one or more arguments) - nargs="*" → Vec<T> (zero or more arguments) - nargs="?" → Option<T> (optional single argument) **Phase 4: action Parameter Support** - action="store_true" → bool (flag sets to true) - action="store_false" → bool (flag sets to false) - action="count" → u8 (NEW: counts occurrences) ### DEPYLER-0365 Phase 5: Flag Detection Fixes (Commit bc10ed0) **Fixed Critical Bugs**: 1. Long flags incorrectly detected as short 2. Dual short+long flags not handled **Three-case flag detection**: - Short only: -v → #[arg(short = 'v')] - Long only: --debug → #[arg(long)] - Dual: -o --output → #[arg(short = 'o', long)] ## Real-World Validation Successfully transpiled examples/argparse_cli/python/wordcount.py - a production-quality CLI tool with all argparse features. ## Quality Metrics - Tests: 3,140/3,140 passing (100%) - Clippy: Zero warnings - Real-world validation: ✅ ## Documentation Updates - Updated CHANGELOG.md with comprehensive release notes - Updated README.md with v3.19.30 features and examples - Version bump: 3.19.29 → 3.19.30 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bc10ed0 commit ef82ece

File tree

3 files changed

+126
-18
lines changed

3 files changed

+126
-18
lines changed

CHANGELOG.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,99 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## [3.19.30] - 2025-11-11
8+
9+
### ✨ Features: Production-Ready ArgumentParser → Clap Transpilation
10+
11+
**Tickets**: DEPYLER-0364, DEPYLER-0365 Phase 5
12+
**Impact**: Python CLI tools with argparse can now transpile to idiomatic Rust with clap derive macros
13+
**Test Status**: ✅ 3,140 tests passing (0 failures)
14+
15+
#### DEPYLER-0364: nargs & action Mapping (Commit f16b66a)
16+
17+
**Phase 3: nargs Parameter Support**
18+
- ✅ `nargs="+"` → `Vec<T>` (one or more arguments)
19+
- ✅ `nargs="*"` → `Vec<T>` (zero or more arguments)
20+
- ✅ `nargs="?"` → `Option<T>` (optional single argument)
21+
22+
**Phase 4: action Parameter Support**
23+
- ✅ `action="store_true"` → `bool` (flag sets to true)
24+
- ✅ `action="store_false"` → `bool` (flag sets to false)
25+
- ✅ `action="count"` → `u8` (NEW: counts occurrences: `-v -v -v` → 3)
26+
27+
**Files Modified**:
28+
- `crates/depyler-core/src/rust_gen/stmt_gen.rs` - kwargs extraction from add_argument()
29+
- `crates/depyler-core/src/rust_gen/argparse_transform.rs` - type mapping logic
30+
31+
#### DEPYLER-0365 Phase 5: Flag Detection Fixes (Commit bc10ed0)
32+
33+
**Fixed Two Critical Bugs**:
34+
35+
1. **Long flags incorrectly detected as short**
36+
- Before: `--debug` → `#[arg(short = 'd')]` ❌
37+
- After: `--debug` → `#[arg(long)]` ✅
38+
39+
2. **Dual short+long flags not handled**
40+
- Before: `-o --output` → only `-o` read, field name=`o` ❌
41+
- After: `-o --output` → `#[arg(short = 'o', long)]`, field name=`output` ✅
42+
43+
**Implementation**:
44+
- Added `args.get(1)` to handle second argument (long flag) in `stmt_gen.rs:160-172`
45+
- Three-case flag detection logic in `argparse_transform.rs:319-348`
46+
47+
#### Real-World Validation
48+
49+
Successfully transpiled `examples/argparse_cli/python/wordcount.py` - a production-quality CLI tool with:
50+
- Positional arguments with nargs
51+
- Multiple dual short+long flags
52+
- Type mapping (Path → PathBuf)
53+
- help text and descriptions
54+
55+
**Generated Code Example**:
56+
```rust
57+
#[derive(clap::Parser)]
58+
#[command(about = "Count lines, words, and characters in files")]
59+
#[command(after_help = "Similar to wc(1) Unix command")]
60+
struct Args {
61+
#[doc = "Files to process"]
62+
files: Vec<PathBuf>,
63+
64+
#[arg(short = 'l', long)]
65+
#[doc = "Show only line count"]
66+
lines: bool,
67+
68+
#[arg(short = 'w', long)]
69+
#[doc = "Show only word count"]
70+
words: bool,
71+
}
72+
```
73+
74+
#### ArgumentParser Support Status
75+
76+
| Feature | Status | Example |
77+
|---------|--------|---------|
78+
| Positional args | ✅ Complete | `"input_file"` → `input_file: PathBuf` |
79+
| Short flags | ✅ Complete | `"-v"` → `#[arg(short = 'v')]` |
80+
| Long flags | ✅ Complete | `"--debug"` → `#[arg(long)]` |
81+
| Dual flags | ✅ Complete | `"-o", "--output"` → `#[arg(short = 'o', long)]` |
82+
| Type mapping | ✅ Complete | `type=int` → `i32`, `type=Path` → `PathBuf` |
83+
| nargs | ✅ Complete | `nargs="+"` → `Vec<T>` |
84+
| action | ✅ Complete | `action="count"` → `u8` |
85+
| help text | ✅ Complete | `help="..."` → `#[doc = "..."]` |
86+
| description | ✅ Complete | `description="..."` → `#[command(about = "...")]` |
87+
| epilog | ✅ Complete | `epilog="..."` → `#[command(after_help = "...")]` |
88+
89+
### 🐛 Bug Fixes
90+
91+
- Fixed redundant closures in argparse_transform.rs (clippy::redundant_closure)
92+
- Fixed collapsible if let in stmt_gen.rs (clippy::collapsible_match)
93+
- Fixed useless format! at stmt_gen.rs:1444
94+
95+
### 📚 Documentation
96+
97+
- Updated `docs/bugs/DEPYLER-0364-hir-kwargs-support.md` with implementation details
98+
- Updated `docs/bugs/DEPYLER-0365-argparse-production-roadmap.md` with Phase 5 completion
99+
7100
### 🛑 DEPYLER-0269/0270: STOP THE LINE - Test Failures Blocking Release (2025-11-07)
8101

9102
**Status**: 🔴 ACTIVE - P0 BLOCKER - 3 test failures

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ max_cyclomatic_complexity = 15
1919
required_documentation_coverage = 100.0
2020

2121
[workspace.package]
22-
version = "3.19.29"
22+
version = "3.19.30"
2323
edition = "2021"
2424
authors = ["Depyler Contributors"]
2525
license = "MIT OR Apache-2.0"

README.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,51 @@
1212

1313
A Python-to-Rust transpiler with semantic verification and memory safety analysis. Depyler translates annotated Python code into idiomatic Rust, preserving program semantics while providing compile-time safety guarantees.
1414

15-
## 🎉 Current Release: v3.19.14 - 100% Stdlib Collection Coverage!
15+
## 🎉 Current Release: v3.19.30 - Production-Ready ArgumentParser Support!
1616

17-
**Major Milestone Achieved** - Complete coverage of Python stdlib collection methods:
17+
**Major Feature** - Python CLI tools with argparse can now transpile to idiomatic Rust with clap derive macros!
1818

19-
### What's New in v3.19.14
19+
### What's New in v3.19.30
2020

21-
**Stdlib Coverage: 100% (40/40 methods)**
22-
-**List methods** (11/11): append, extend, insert, remove, pop, clear, index, count, sort, reverse, copy
23-
-**Dict methods** (10/10): get, keys, values, items, pop, clear, update, setdefault, popitem, copy
24-
-**Set methods** (8/8): add, remove, discard, pop, clear, union, intersection, difference
25-
-**String methods** (11/11): upper, lower, strip, startswith, endswith, split, join, find, replace, count, isdigit, isalpha
21+
**ArgumentParser → Clap Transpilation** (DEPYLER-0364, DEPYLER-0365)
22+
-**nargs mapping**: `"+"`, `"*"`, `"?"``Vec<T>`, `Option<T>`
23+
-**action mapping**: `store_true`, `store_false`, `count``bool`, `u8`
24+
-**type mapping**: `int`, `str`, `Path``i32`, `String`, `PathBuf`
25+
-**Flag detection**: Short (`-v`), long (`--debug`), dual (`-o --output`)
26+
-**Real-world validation**: Successfully transpiled production CLI tool (`wordcount.py`)
2627

27-
**Bugs Fixed (4)**
28-
- DEPYLER-0222: dict.get() without default value
29-
- DEPYLER-0223: dict.update() and set.update() routing
30-
- DEPYLER-0225: str.split(sep) Pattern trait error
31-
- DEPYLER-0226: str.count() routing disambiguation
28+
**Example:**
29+
```python
30+
# Python with argparse
31+
parser = argparse.ArgumentParser(description="Word counter")
32+
parser.add_argument("files", nargs="+", type=Path)
33+
parser.add_argument("-l", "--lines", action="store_true")
34+
args = parser.parse_args()
35+
```
36+
37+
**Transpiles to:**
38+
```rust
39+
#[derive(clap::Parser)]
40+
#[command(about = "Word counter")]
41+
struct Args {
42+
files: Vec<PathBuf>,
43+
#[arg(short = 'l', long)]
44+
lines: bool,
45+
}
46+
let args = Args::parse();
47+
```
3248

3349
**Quality Metrics**
34-
- Tests: 443/443 passing (100%)
50+
- Tests: 3,140/3,140 passing (100%)
3551
- Clippy: Zero warnings
36-
- Coverage: 80%+
37-
- Zero regressions
52+
- Real-world validation: ✅ Production CLI tools transpile correctly
3853

3954
**Installation**
4055
```bash
4156
cargo install depyler
4257
```
4358

44-
See [CHANGELOG.md](CHANGELOG.md) for complete details and [GitHub Release](https://github.com/paiml/depyler/releases/tag/v3.19.14).
59+
See [CHANGELOG.md](CHANGELOG.md) for complete details.
4560

4661
## Installation
4762

0 commit comments

Comments
 (0)