Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 275
Some Name Avatar asked Oct 23 '25 23:10

Some Name


1 Answers

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.

like image 91
eggyal Avatar answered Oct 25 '25 14:10

eggyal