Skip to content
/ cli-rust Public template

Template for Command Line Interface (CLI) tool in Rust

License

Notifications You must be signed in to change notification settings

swiftsoftwaregroup/cli-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cli-rust

Template for Command Line Interface (CLI) tool in Rust

Development

Setup for macOS

Install rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Test:

source $HOME/.cargo/env
rustc --help

Work on macOS

Configure project:

source configure.sh

Open the project in Visual Studio Code:

code .

Build

cargo build

Run

Run the compiled binary

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!

Run through cargo

cargo run greet name.txt
cargo run greet --language es name.txt
cargo run greet -l bg name.txt

Test

cargo test

Generate Docs

cargo doc

Browse docs:

cargo doc --open

How to create a new project

# create new project
cargo init

# add packages
# see: https://crates.io/crates/clap
cargo add clap --features derive
cargo add tempfile --dev

About

Template for Command Line Interface (CLI) tool in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published