-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 82fb0e5
Showing
11 changed files
with
689 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo clippy -- -D warnings | ||
- run: cargo fmt -- --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
|
||
# Added by cargo | ||
|
||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "demand" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "A CLI prompt library" | ||
license = "MIT" | ||
repository = "https://github.com/jdx/demand" | ||
readme = "README.md" | ||
keywords = ["cli", "prompt", "console"] | ||
files = ["src", "Cargo.toml", "README.md", "LICENSE"] | ||
|
||
[dependencies] | ||
console = "0.15" | ||
termcolor = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 jdx | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# demand | ||
|
||
![Crates.io](https://img.shields.io/crates/d/demand) | ||
![docs.rs](https://img.shields.io/docsrs/demand) | ||
![GitHub License](https://img.shields.io/github/license/jdx/demand) | ||
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jdx/demand/test.yml) | ||
![GitHub issues](https://img.shields.io/github/issues/jdx/demand) | ||
|
||
A prompt library for Rust. Based on [huh? for Go](https://github.com/charmbracelet/huh). | ||
|
||
## Input | ||
|
||
Single-line text input. | ||
|
||
TODO | ||
|
||
## Text | ||
|
||
Multi-line text input. | ||
|
||
TODO | ||
|
||
## Select | ||
|
||
Select from a list of options. | ||
|
||
TODO | ||
|
||
## Multiselect | ||
|
||
Select multiple options from a list. | ||
Run example with [`cargo run --example multiselect`](./examples/multiselect.rs). | ||
|
||
![Multiselect](./assets/multiselect.png) | ||
|
||
```rust | ||
use demand::{DemandOption, MultiSelect}; | ||
|
||
fn main() { | ||
let ms = MultiSelect::new("Toppings") | ||
.description("Select your toppings") | ||
.min(1) | ||
.max(4) | ||
.filterable(true) | ||
.option(DemandOption::new("Lettuce").selected(true)) | ||
.option(DemandOption::new("Tomatoes").selected(true)) | ||
.option(DemandOption::new("Charm Sauce")) | ||
.option(DemandOption::new("Jalapenos").label("Jalapeños")) | ||
.option(DemandOption::new("Cheese")) | ||
.option(DemandOption::new("Vegan Cheese")) | ||
.option(DemandOption::new("Nutella")); | ||
ms.run().expect("error running multi select"); | ||
} | ||
``` | ||
|
||
## Confirm | ||
|
||
Confirm a question with a yes or no. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use demand::{DemandOption, MultiSelect}; | ||
|
||
fn main() { | ||
let ms = MultiSelect::new("Toppings") | ||
.description("Select your toppings") | ||
.min(1) | ||
.max(4) | ||
.filterable(true) | ||
.option(DemandOption::new("Lettuce").selected(true)) | ||
.option(DemandOption::new("Tomatoes").selected(true)) | ||
.option(DemandOption::new("Charm Sauce")) | ||
.option(DemandOption::new("Jalapenos").label("Jalapeños")) | ||
.option(DemandOption::new("Cheese")) | ||
.option(DemandOption::new("Vegan Cheese")) | ||
.option(DemandOption::new("Nutella")); | ||
ms.run().expect("error running multi select"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//! A prompt library for Rust. Based on [huh? for Go](https://github.com/charmbracelet/huh). | ||
pub use multiselect::MultiSelect; | ||
pub use option::DemandOption; | ||
pub use theme::Theme; | ||
|
||
mod multiselect; | ||
mod option; | ||
mod theme; |
Oops, something went wrong.