3 ms·
I often see people recommend Go for CLI apps but I'm not sure why. The built-in `flag` package is really limiting. These days I mostly use Rust with `clap` whic
by dmart 5y ago
I often see people recommend Go for CLI apps but I'm not sure why. The built-in `flag` package is really limiting. These days I mostly use Rust with `clap` which is the nicest flag-parsing experience I've found so far in any language.
- alain_gilbert 5y agoAre you using "clap" because the "built-in" one in rust is not good? :P
- cesarb 5y agoThere is no "built-in" command line parser in Rust. All it has is std::env::args (https://doc.rust-lang.org/std/env/fn.args.html https://doc.rust-lang.org/std/env/fn.args.html) and std::env::args_os (https://doc.rust-lang.org/std/env/fn.args_os.html https://doc.rust-lang.org/std/env/fn.args_os.html), which give you the raw command line. Rust does not follow the "batteries included" philosophy for its base standard library, to avoid "leaking batteries" problems like seen for instance with Python (https://news.ycombinator.com/item?id=19948642 https://news.ycombinator.com/item?id=19948642).
- alain_gilbert 5y agoI know there is no flag library built-in in rust (I do quite a lot of rust as well as go). That's my whole point. It should be compared to something like https://github.com/urfave/cli https://github.com/urfave/cli . That would be a fairer comparison.
- dmart 5y agoSure, for example I usually use Cobra. But what I meant was that people often mention Go as being explicitly preferable to Rust for CLIs, and I’m not sure why if I have to pull in a dependency in either case.