Add recursive dependency downloading and directory scanning

- Implement recursive downloading of nested dependencies from ZON files
- Enhance CLI to support downloading from directories containing `build.zig.zon` files
- Update README with new usage instructions and command options
- Refactor dependency processing to handle both single files and directories
This commit is contained in:
2025-03-19 11:22:46 +08:00
parent 09cbad23d6
commit cc0d988012
3 changed files with 189 additions and 21 deletions

View File

@ -7,6 +7,8 @@ A Python utility for working with Zig package manager files and Zig Object Notat
- Parse ZON files into Python dictionaries
- Convert ZON files to JSON
- Download and extract dependencies from ZON files
- Recursively download nested dependencies
- Scan directories for `build.zig.zon` files
## Installation
@ -59,13 +61,27 @@ The package provides a command-line interface with the following commands:
#### Download Dependencies
Download and extract dependencies from a ZON file:
Download dependencies from a ZON file or directory:
```bash
uv run zig-fetch download examples/test.zon
# Download dependencies from a single ZON file
zig-fetch download examples/test.zon
# Download dependencies from a directory (finds all build.zig.zon files)
zig-fetch download lib/
# Download dependencies recursively (finds dependencies of dependencies)
zig-fetch -v download examples/test.zon --recursive
# Combine directory scanning with recursive downloading
zig-fetch -v download lib/ --recursive
```
This will download all dependencies specified in the ZON file to `~/.cache/zig/p` and extract them to directories named after their hash values.
Options:
- `--recursive`, `-r`: Recursively process dependencies of dependencies
- `--verbose`, `-v`: Enable verbose logging (on the parent command)
This will download all dependencies to `~/.cache/zig/p` and extract them to directories named after their hash values.
#### Convert ZON to JSON