This repository shows a basic setup for a command line application in Rust.
Rust is expected to be installed on your system.
After cloning this repository, change into the newly created directory and run
cargo build
This will download all dependencies needed for the project and build/compile it.
All tests can be run by executing
cargo test
test
will automatically run all tests found in the source modules.
The test for function example::message
is only verifying the return value of it.
Testing main::print_messaage
on the other hand is done via a test-double that gets injected.
This allows us to spy on the output it produces.
We want to avoid printing anything to the screen while running the tests.
Injecting a test double in this instance is a nice way to isolate our application from the command line.
To run the application we can run it with cargo: cargo run
.
You should see the text “Rust Example” being printed.
$: cargo run
Compiling rust-command-line v0.1.0 (/home/vanilla/rust-command-line)
Finished dev [unoptimized + debuginfo] target(s) in 1.90s
Running `target/debug/rust-command-line`
Rust Example
This project is licensed under the MIT License - see the license.md file for details.