简体   繁体   中英

Pass default arguments to cargo run

I have the following binary crate source structure:

prj
 |
 |__config
 |    |___conf.toml
 |
 |___src
 |    |_...
 |
 |__Cargo.toml

So when performing cargo run I expect the following command to run bin /path/to/prj/config/conf.toml .

Is it possible to config cargo run in Cargo.toml so it passes the absolute path to the config/conf.toml without passing it explicitly every time ?

Is it possible to config cargo run in Cargo.toml so it passes the absolute path to the config/conf.toml without passing it explicitly every time?

Not exactly , but Cargo can be configured with command aliases in its configuration files . For example, you could place the following into ${PROJECT_ROOT}/.cargo/config.toml :

[alias]
runx = "run /path/to/config/conf.toml"

And then you'd just do cargo runx .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM