https://github.com/swiftsoftwaregroup/cli-rust
Template for Command Line Interface (CLI) tool in Rust
https://github.com/swiftsoftwaregroup/cli-rust
Last synced: 5 months ago
JSON representation
Template for Command Line Interface (CLI) tool in Rust
- Host: GitHub
- URL: https://github.com/swiftsoftwaregroup/cli-rust
- Owner: swiftsoftwaregroup
- License: apache-2.0
- Created: 2024-07-10T07:02:20.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-10T17:11:26.000Z (almost 2 years ago)
- Last Synced: 2025-10-14T11:43:13.061Z (9 months ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cli-rust
Template for Command Line Interface (CLI) tool in Rust
## Development
### Setup for macOS
Install `rustup`:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
Test:
```bash
source $HOME/.cargo/env
rustc --help
```
### Work on macOS
Configure project:
```bash
source configure.sh
```
Open the project in Visual Studio Code:
```bash
code .
```
### Build
```bash
cargo build
```
### Run
#### Run the compiled binary
```bash
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:
```bash
Hello, John!
Hola, John!
Здравей, John!
```
#### Run through `cargo`
```bash
cargo run greet name.txt
cargo run greet --language es name.txt
cargo run greet -l bg name.txt
```
### Test
```bash
cargo test
```
### Generate Docs
```bash
cargo doc
```
Browse docs:
```bash
cargo doc --open
```
### How to create a new project
```bash
# create new project
cargo init
# add packages
# see: https://crates.io/crates/clap
cargo add clap --features derive
cargo add tempfile --dev
```