Comment on Zig 0.16.0 Release NotesComments−sionisrecur4moThe "Juicy Main" looks like a very nice QoL feature. Gets rid of all the boilerplate for allocators and argv.−mihaelm4moIt's the dark horse of this release as CLI parsing can also be more easily built on top of it. There's a couple of proposals floating around now, so I hope we get something soon-ish (maybe in 0.18 since a short cyle is planned for 0.17).−fredyr4moThis sounds interesting to me - could you elaborate a little on what things are in those proposals?−mihaelm4moSure, this is the issue tracking the work: https://codeberg.org/ziglang/zig/issues/30677The idea is to offer some kind of CLI parsing in the std. It says minimal, but the discussion also veers into some more advanced options.The discussion resulted in two PRs (that I know of):- Type-driven: https://codeberg.org/ziglang/zig/issues/30677@dotcarmen extracted it into a package (https://codeberg.org/dotcarmen/clip) so people could more easily try it out.- Composition-based: https://codeberg.org/ziglang/zig/pulls/31620If you're familiar with Rust's clap, it's a bit like derive vs builder API.You can also see how each approach would look in practice if you inspect the diff for the "tools" directory on the PRs.−fredyr4moThanks!−anttiharju4moclap's derive is so nice−portly4moDo I get it right that this is everything you need for a typical CLI tool?−nesarkvechnep4moYou got that right.−portly4moThat's clean.
Comments
The "Juicy Main" looks like a very nice QoL feature. Gets rid of all the boilerplate for allocators and argv.
It's the dark horse of this release as CLI parsing can also be more easily built on top of it. There's a couple of proposals floating around now, so I hope we get something soon-ish (maybe in 0.18 since a short cyle is planned for 0.17).
This sounds interesting to me - could you elaborate a little on what things are in those proposals?
Sure, this is the issue tracking the work: https://codeberg.org/ziglang/zig/issues/30677
The idea is to offer some kind of CLI parsing in the std. It says minimal, but the discussion also veers into some more advanced options.
The discussion resulted in two PRs (that I know of):
- Type-driven: https://codeberg.org/ziglang/zig/issues/30677
@dotcarmen extracted it into a package (https://codeberg.org/dotcarmen/clip) so people could more easily try it out.
- Composition-based: https://codeberg.org/ziglang/zig/pulls/31620
If you're familiar with Rust's clap, it's a bit like derive vs builder API.
You can also see how each approach would look in practice if you inspect the diff for the "tools" directory on the PRs.
Thanks!
clap's derive is so nice
Do I get it right that this is everything you need for a typical CLI tool?
You got that right.
That's clean.