Skip to content

Commit

Permalink
Merge pull request #6 from wadackel/fix/placeholder-bugs
Browse files Browse the repository at this point in the history
Fix placeholder bugs
  • Loading branch information
wadackel authored Jan 14, 2024
2 parents 443216b + 82dfe38 commit 4c76a1e
Show file tree
Hide file tree
Showing 29 changed files with 456 additions and 35 deletions.
80 changes: 68 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Number](#number)
- [Select](#select)
- [MultiSelect](#multiselect)
- [Confirm](#confirm)
- [Autocomplete](#autocomplete)
- [Themes](#themes)
- [MinimalTheme](#minimaltheme)
Expand Down Expand Up @@ -113,27 +114,48 @@ To implement your original prompt, please see the [Build your own Prompt](#build

### Input

![Input Screenshot](./assets/prompt_input.png)
![Input Demo](./assets/prompt_input.gif)

A prompt for general text input.

```rust
let name = p.prompt(Input::new("What is your accout name?").with_hint("e.g. wadackel"))?;
let name = p.prompt(
Input::new("What is your accout name?")
.with_placeholder("username")
.with_hint("Only alphanumeric characters are allowed.")
.with_validator(|value: &String| {
if value.chars().all(|c| c.is_alphanumeric()) {
Ok(())
} else {
Err("Invalid format".into())
}
}),
)?;
```

### Password

![Password Screenshot](./assets/prompt_password.png)
![Password Demo](./assets/prompt_password.gif)

A text input prompt where the input is not displayed.

```rust
let secret = p.prompt(Password::new("What is your password?").with_required(false))?;
let secret = p.prompt(
Password::new("Set a password for your account")
.with_hint("Please enter more than 6 alphanumeric characters.")
.with_validator(|value: &String| {
if value.len() < 6 {
Err("Password must be at least 6 characters long".into())
} else {
Ok(())
}
}),
)?;
```

### Number

![Number Screenshot](./assets/prompt_number.png)
![Number Demo](./assets/prompt_number.gif)

A prompt for inputting only integer values.

Expand All @@ -143,7 +165,7 @@ let age = p.prompt(Number::new("How old are you?").with_min(0).with_max(120))?;

### Select

![Select Screenshot](./assets/prompt_select.png)
![Select Demo](./assets/prompt_select.gif)

A prompt for selecting a single element from a list of options.

Expand All @@ -155,27 +177,43 @@ let color = p.prompt(
SelectOption::new("Red", "#ff0000"),
SelectOption::new("Green", "#00ff00").with_hint("recommended"),
SelectOption::new("Blue", "#0000ff"),
])
.with_page_size(5)
],
)
.as_mut(),
)?;
```

### MultiSelect

![MultiSelect Screenshot](./assets/prompt_multi_select.png)
![MultiSelect Demo](./assets/prompt_multi_select.gif)

A prompt for selecting multiple elements from a list of options.

```rust
let color = p.prompt(
MultiSelect::new(
"What is your favorite color?",
"What are your favorite colors?",
vec![
MultiSelectOption::new("Red", "#ff0000"),
MultiSelectOption::new("Green", "#00ff00").with_hint("recommended"),
MultiSelectOption::new("Blue", "#0000ff"),
])
.with_page_size(5)
],
)
.as_mut(),
)?;
```

### Confirm

![Confirm Demo](./assets/prompt_confirm.gif)

A prompt for inputting a Yes/No choice.

```rust
let like = p.prompt(
Confirm::new("Do you like dogs?")
.with_hint("This is just a sample prompt :)")
.with_default(true),
)?;
```

Expand All @@ -196,12 +234,30 @@ MinimalTheme is similar to [Inquirer](https://github.com/SBoudrias/Inquirer.js).

![MinimalTheme Screenshot](./assets/theme_minimal.png)

```rust
use promptuity::themes::MinimalTheme;

fn main() {
let mut theme = MinimalTheme::default();
// ...
}
```

### FancyTheme

FancyTheme is similar to [clack](https://github.com/natemoo-re/clack). It provides a rich UI.

![FancyTheme Screenshot](./assets/theme_fancy.png)

```rust
use promptuity::themes::FancyTheme;

fn main() {
let mut theme = FancyTheme::default();
// ...
}
```

## Customize

This section provides guidance on how to construct original prompts and Themes.
Expand Down
Binary file added assets/prompt_confirm.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions assets/prompt_confirm.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Require cargo
Set Shell "zsh"
Set Theme "Dracula+"
Set WindowBar Colorful
Set WindowBarSize 60
Set Margin 24
Set MarginFill "#f0f4f7"
Set Padding 36
Set BorderRadius 16
Set CursorBlink false
Set FontSize 30
Set TypingSpeed 120ms

Set Width 1500
Set Height 500
Output assets/prompt_confirm.gif

Type@40ms "cargo run --example prompt_confirm" Enter
Sleep 3s

Right Sleep 1.5s
Left Sleep 1.5s
Enter

Sleep 5s
Binary file added assets/prompt_input.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/prompt_input.png
Binary file not shown.
25 changes: 25 additions & 0 deletions assets/prompt_input.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Require cargo
Set Shell "zsh"
Set Theme "Dracula+"
Set WindowBar Colorful
Set WindowBarSize 60
Set Margin 24
Set MarginFill "#f0f4f7"
Set Padding 36
Set BorderRadius 16
Set CursorBlink false
Set FontSize 30
Set TypingSpeed 120ms

Set Width 1500
Set Height 500
Output assets/prompt_input.gif

Type@40ms "cargo run --example prompt_input" Enter
Sleep 3s

Type "foo bar" Sleep 1s Enter
Sleep 3s Ctrl+W Sleep 100ms Ctrl+W Sleep 500ms Enter
Sleep 3s Type "wadackel" Sleep 2s Enter

Sleep 5s
Binary file added assets/prompt_multi_select.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/prompt_multi_select.png
Binary file not shown.
25 changes: 25 additions & 0 deletions assets/prompt_multi_select.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Require cargo
Set Shell "zsh"
Set Theme "Dracula+"
Set WindowBar Colorful
Set WindowBarSize 60
Set Margin 24
Set MarginFill "#f0f4f7"
Set Padding 36
Set BorderRadius 16
Set CursorBlink false
Set FontSize 30
Set TypingSpeed 120ms

Set Width 1500
Set Height 500
Output assets/prompt_multi_select.gif

Type@40ms "cargo run --example prompt_multi_select" Enter
Sleep 3s

Down Type "j" Sleep 1s
Space Type "k" Sleep 1s
Space Sleep 1s Enter

Sleep 5s
Binary file added assets/prompt_number.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/prompt_number.png
Binary file not shown.
26 changes: 26 additions & 0 deletions assets/prompt_number.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Require cargo
Set Shell "zsh"
Set Theme "Dracula+"
Set WindowBar Colorful
Set WindowBarSize 60
Set Margin 24
Set MarginFill "#f0f4f7"
Set Padding 36
Set BorderRadius 16
Set CursorBlink false
Set FontSize 30
Set TypingSpeed 120ms

Set Width 1500
Set Height 500
Output assets/prompt_number.gif

Type@40ms "cargo run --example prompt_number" Enter
Sleep 3s

Type "123" Sleep 1s Enter
Sleep 3s Ctrl+U Sleep 1s
Type "30" Sleep 1s
Up Sleep 1s Enter

Sleep 5s
Binary file added assets/prompt_password.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/prompt_password.png
Binary file not shown.
25 changes: 25 additions & 0 deletions assets/prompt_password.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Require cargo
Set Shell "zsh"
Set Theme "Dracula+"
Set WindowBar Colorful
Set WindowBarSize 60
Set Margin 24
Set MarginFill "#f0f4f7"
Set Padding 36
Set BorderRadius 16
Set CursorBlink false
Set FontSize 30
Set TypingSpeed 120ms

Set Width 1500
Set Height 500
Output assets/prompt_password.gif

Type@40ms "cargo run --example prompt_password" Enter
Sleep 3s

Type "123" Sleep 1s Enter
Sleep 3s Ctrl+U Sleep 1s Enter
Sleep 3s Type "secret123" Sleep 2s Enter

Sleep 5s
Binary file added assets/prompt_select.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/prompt_select.png
Binary file not shown.
24 changes: 24 additions & 0 deletions assets/prompt_select.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Require cargo
Set Shell "zsh"
Set Theme "Dracula+"
Set WindowBar Colorful
Set WindowBarSize 60
Set Margin 24
Set MarginFill "#f0f4f7"
Set Padding 36
Set BorderRadius 16
Set CursorBlink false
Set FontSize 30
Set TypingSpeed 120ms

Set Width 1500
Set Height 500
Output assets/prompt_select.gif

Type@40ms "cargo run --example prompt_select" Enter
Sleep 3s

Down Type "j" Sleep 1s
Up Sleep 1s Enter

Sleep 5s
Binary file modified assets/quick_start.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/quick_start.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Require cargo
Set Shell "zsh"
Set Theme "Dracula+"
Set WindowBar Colorful
Set WindowBarSize 60
Set Margin 24
Set MarginFill "#f0f4f7"
Set Padding 36
Set BorderRadius 16
Set CursorBlink false
Set FontSize 30
Set TypingSpeed 120ms

Set Width 1500
Set Height 900
Output assets/quick_start.gif

Type@40ms "cargo run --example quick_start" Sleep 300ms Enter
Sleep 4s

Type "empty test" Sleep 1s Backspace 10 Sleep 500ms Enter Sleep 3s
Type "wadackel" Sleep 2s Enter
Sleep 2s Right Sleep 2s Left Sleep 2s Enter
Sleep 2s Down 11 Sleep 2s Up 11 Sleep 2s Enter

Sleep 5s
Loading

0 comments on commit 4c76a1e

Please sign in to comment.