A simple interactive CLI made in Rust
- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| examples | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
dv's interactive cli rs
A simple interactive CLI tool made in Rust.
Usage
First of all, you're gonna need to add dvs-interactive-cli-rs to your Cargo.toml
[dependencies]
dvs-interactive-cli-rs = { git = "https://codeberg.org/dvs/dvs-interactive-cli-rs.git", branch = "main" }
Boolean
use dvs_interactive_cli_rs::boolean;
fn main() {
let thoughts_about = boolean("What do you think about solar panels?");
boolean("Do you exist?");
boolean("What is your purpose?");
println!("{}", thoughts_about);
}
- File example; @examples/boolean.rs
- Arguments;
- String -> Show a question
- Return examples;
- Returns the user's input ->
y/Y/n/N-> String
- Returns the user's input ->
Input
use dvs_interactive_cli_rs::input;
fn main() {
let how_day = input("How many days are in a week?", &true, "Maybe...");
input("Do you exist?", &false, "I can if I wanted to");
input("What are you without the universe?", &false, "");
input("Input nothing in this one.", &true, "");
println!("{}", how_day);
}
- File example; @examples/input.rs
- Arguments;
- String -> Show a question
- Boolean -> Required field (shows a red asterisk
*) - String -> Shows a placeholder
- Return examples;
- Returns the user's input ->
Hello, world!-> String
- Returns the user's input ->
Choices
use dvs_interactive_cli_rs::choices;
fn main() {
let i_want = choices("What do you want?", ["this one", "that one", "all of them"].as_slice(), &true, &true);
choices("More of them?", ["yes, this one", "yes, that one", "yes, all of them", "we5y0w3895h"].as_slice(), &false, &true);
choices("Why?", ["yes, this one", "yes, that one"].as_slice(), &true, &false);
choices("Okay?", ["yes, this one"].as_slice(), &false, &false);
for num in i_want {
println!("{}", num);
}
}
- File example; @examples/input.rs
- Arguments;
- String -> Show a question
- Array -> Choices for the user to select
- Boolean -> Mutli selection
- Boolean -> Required field (shows a red asterisk
*)
- Return examples;
- Single option ->
[1]-> Vec - Multi option ->
[1, 2, 3]-> Vec
- Single option ->
License
This project is licensed under the MIT license.