Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
How to pass command line arguments when using cargo run?
When developing a rust program you build and run using cargo run
. However you cannot just append arguments to that as they will be caught (and likely rejected) by cargo itself. So how to pass arguments through cargo run to the actual program under development?
1 answer
Specify your arguments after --
:
cargo run --offline -- --my-argument 42
--offline
is just an example of cargo's own argument. They are passed before --
.
--my-argument
and 42
will be passed to your program.
Source: The Cargo Book
1 comment thread