Template for Command Line Interface (CLI) tool in Rust
Install rustup
:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Test:
source $HOME/.cargo/env
rustc --help
Configure project:
source configure.sh
Open the project in Visual Studio Code:
code .
cargo build
pushd ./target/debug
./cli-rust
echo "John" > name.txt
./cli-rust greet name.txt
./cli-rust greet --language es name.txt
./cli-rust greet -l bg name.txt
popd
Output:
Hello, John!
Hola, John!
Здравей, John!
cargo run greet name.txt
cargo run greet --language es name.txt
cargo run greet -l bg name.txt
cargo test
cargo doc
Browse docs:
cargo doc --open
# create new project
cargo init
# add packages
# see: https://crates.io/crates/clap
cargo add clap --features derive
cargo add tempfile --dev