mirror of https://github.com/bazelbuild/rules_rust
fa943c7f16
This change introduces the `action_args` crate which is something I feel I keep writing in various repos now. It's original design is to make it easier to pass args to built binaries. E.g. ```rust use action_args; use clap::Parser; use runfiles::{rlocation, Runfiles}; #[command(version, about, long_about = None)] struct ClapArgs {} fn main() { let args = { let runfiles = Runfiles::create().unwrap(); let var = std::env::var("ARGS_FILE").unwrap(); let runfile = rlocation!(runfiles, var).unwrap(); let text = std::fs::read_to_string(runfile).unwrap(); let argv = action_args::parse_args(text); ClapArgs::parse_from(std::env::args().take(1).chain(argv)) }; // ... // ... // ... } ``` This utility will likely be unnecessary should https://github.com/bazelbuild/bazel/issues/16076 ever be implemented. Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com> |
||
---|---|---|
.. | ||
BUILD.bazel | ||
action_args.rs |