Compare commits

...

11 Commits

Author SHA1 Message Date
Lutetium-Vanadium c454826c25 Fix clippy warnings and publish 0.5.0 2022-09-01 18:49:34 +05:30
Lutetium-Vanadium e27b63b5cf Fix msrv issue 2022-09-01 18:25:07 +05:30
Lutetium-Vanadium 52fa177a13 Update deps and fix doc compilation issues 2022-09-01 18:24:28 +05:30
Lutetium-Vanadium dc98a89e3e Use winsplit to split editor commands on windows 2022-09-01 17:54:30 +05:30
Lutetium-Vanadium 4228c51459
Merge pull request #14 from kellygravelyn/split-editor-command
Use shell-words to split editor command
2022-09-01 17:39:45 +05:30
Lutetium-Vanadium 2e5ef595b1 Add gif, update macro implementation and fix few errors 2022-09-01 17:29:03 +05:30
NovaliX-Dev 09c9a0b7fc added snapshots 2022-09-01 13:01:29 +02:00
NovaliX-Dev 7a413c3021 small name fix 2022-09-01 13:01:12 +02:00
NovaliX-Dev 684e71d06c moved conversion trait from OrderSelectItem to ListItem 2022-09-01 13:00:14 +02:00
NovaliX-Dev 378f506bbb Updated index so they increment from 1 instead of 0 2022-09-01 08:06:53 +02:00
Kelly Gravelyn 5032b46fb7 Use shell-words to split editor command 2022-07-12 12:33:05 -07:00
108 changed files with 1831 additions and 237 deletions

View File

@ -1,13 +1,32 @@
# Changelog
## `0.4.1`
## `0.5.0`
## `0.4.0`
- `requestty`
- Update the way indices are shown in `RawSelect`
- Added `OrderSelect` (#16)
- [bug fix] Support multi-word editor commands (#14)
- `requestty-ui`
- [bug fix] Add support for rendering wide characters. (#18, #19 and
#20)
- [bug fix] Show message when prompt's height exceeds the terminal
height. Earlier, it would panic in debug builds due to overflow.
(#17)
## `0.4.1`
- `requestty-ui`
- Remove `dbg!` in `Input`. Fixes #12
## `0.4.0`
The msrv has been bumped up to `1.56`
- `requestty`

View File

@ -1,6 +1,6 @@
[package]
name = "requestty"
version = "0.4.1"
version = "0.5.0"
authors = ["Lutetium Vanadium"]
edition = "2018"
description = "An easy-to-use collection of interactive cli prompts"
@ -21,13 +21,19 @@ members = [
]
[dependencies]
ui = { package = "requestty-ui", path = "./requestty-ui", version = "=0.4.1" }
macro = { package = "requestty-macro", path = "./requestty-macro", optional = true, version = "=0.4.1" }
ui = { package = "requestty-ui", path = "./requestty-ui", version = "=0.5.0" }
macro = { package = "requestty-macro", path = "./requestty-macro", optional = true, version = "=0.5.0" }
tempfile = "3"
smallvec = { version = "1.8", optional = true }
[target.'cfg(unix)'.dependencies]
shell-words = "1.1"
[target.'cfg(windows)'.dependencies]
winsplit = "0.1"
[dev-dependencies]
trybuild = { version = "1.0.42", features = ["diff"] }
# remove color printing since it messes with the snapshot's colours

View File

@ -58,7 +58,7 @@ directory.
## In-built prompts
There are 10 in-built prompts:
There are 11 in-built prompts:
- ### Input
@ -132,6 +132,12 @@ There are 10 in-built prompts:
<img src="./assets/multi-select.gif" style="max-height: 20rem" />
- ### OrderSelect
Prompt that allows the user to organize a list of options.
<img src="./assets/order-select.gif" style="max-height: 20rem" />
## Optional features
- `macros`: Enabling this feature will allow you to use the `questions`

BIN
assets/order-select.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✔ order select · 0, 2, 3, 4, 5, 6, 7, 8, 9, 1 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an opti│
on) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✖ message · Skipped │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an opti│
on) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✔ order select · 1: 1, 0: 0, 2: 2, 3: 3, 4: 4, 5: │
5, 6: 6, 7: 7, 8: 8, 9: 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✔ order select · 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
✖ Error │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 1 │
│ 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 1 │
│ 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 0 │
 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 0 │
 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -1,22 +1,20 @@
---
source: src/question/order_select/tests.rs
assertion_line: 117
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
0. 1
1. 2
2. 3
3. 4
4. 5
5. 6
6. 7
7. 8
8. 9
 9. 0
 1. 0
2. 1
3. 2
4. 3
5. 4
6. 5
7. 6
8. 7
9. 8
10. 9
  │
│ │
│ │

View File

@ -1,13 +1,10 @@
---
source: src/question/order_select/tests.rs
assertion_line: 117
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 0. 0 │
│ 1. 1 │
│ 2. 2 │
│ 3. 3 │
@ -17,6 +14,7 @@ expression: backend
│ 7. 7 │
│ 8. 8 │
│ 9. 9 │
 10. 0 │
  │
│ │
│ │

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -1,22 +1,20 @@
---
source: src/question/order_select/tests.rs
assertion_line: 117
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 0. 0 │
1. 1 │
2. 2 │
3. 3 │
4. 4 │
5. 5 │
6. 6 │
7. 7 │
8. 8 │
9. 9 │
 1. 0 │
2. 1 │
3. 2 │
4. 3 │
5. 4 │
6. 5 │
7. 6 │
8. 7 │
9. 8 │
10. 9 │
  │
│ │
│ │

View File

@ -1,22 +1,20 @@
---
source: src/question/order_select/tests.rs
assertion_line: 117
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 0. 0 │
1. 1 │
2. 2 │
3. 3 │
4. 4 │
5. 5 │
6. 6 │
7. 7 │
8. 8 │
9. 9 │
 1. 0 │
2. 1 │
3. 2 │
4. 3 │
5. 4 │
6. 5 │
7. 6 │
8. 7 │
9. 8 │
10. 9 │
  │
│ │
│ │

View File

@ -1,26 +1,24 @@
---
source: src/question/order_select/tests.rs
assertion_line: 124
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
18. 19
 19. 0
0. 1
1. 2
2. 3
3. 4
4. 5
5. 6
6. 7
7. 8
8. 9
9. 10
│ 10. 11
│ 11. 12
 1. 0
2. 1
3. 2
4. 3
5. 4
6. 5
7. 6
8. 7
9. 8
10. 9
11. 10
12. 11
│ 13. 12
│ 14. 13
(Move up and down to reveal more choices) │
  │
│ │

View File

@ -1,13 +1,12 @@
---
source: src/question/order_select/tests.rs
assertion_line: 124
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 0. 0 │
│ 19. 19 │
 20. 0 │
│ 1. 1 │
│ 2. 2 │
│ 3. 3 │
@ -20,7 +19,6 @@ expression: backend
│ 10. 10 │
│ 11. 11 │
│ 12. 12 │
│ 13. 13 │
(Move up and down to reveal more choices) │
  │
│ │

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
│ 19. 18 │
│ 20. 19 │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ 11. 10 │
│ 12. 11 │
(Move up and down to reveal more choices) │
  │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -1,26 +1,24 @@
---
source: src/question/order_select/tests.rs
assertion_line: 124
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 0. 0
1. 1
2. 2
3. 3
4. 4
5. 5
6. 6
7. 7
8. 8
9. 9
10. 10
│ 11. 11
│ 12. 12
│ 13. 13
19. 18
20. 19
 1. 0
2. 1
3. 2
4. 3
5. 4
6. 5
7. 6
8. 7
9. 8
│ 10. 9
│ 11. 10
│ 12. 11
(Move up and down to reveal more choices) │
  │
│ │

View File

@ -1,26 +1,24 @@
---
source: src/question/order_select/tests.rs
assertion_line: 124
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
18. 18
19. 19
 0. 0
1. 1
2. 2
3. 3
4. 4
5. 5
6. 6
7. 7
8. 8
9. 9
│ 10. 10
│ 11. 11
 1. 0
2. 1
3. 2
4. 3
5. 4
6. 5
7. 6
8. 7
9. 8
10. 9
11. 10
12. 11
│ 13. 12
│ 14. 13
(Move up and down to reveal more choices) │
  │
│ │

View File

@ -41,11 +41,11 @@ fn auto_complete(p: String) -> Completions<String> {
if files.is_empty() {
return completions![p];
} else {
let fuzzer = SkimMatcherV2::default();
files.sort_by_cached_key(|file| fuzzer.fuzzy_match(file, last).unwrap_or(i64::MAX));
files
}
let fuzzer = SkimMatcherV2::default();
files.sort_by_cached_key(|file| fuzzer.fuzzy_match(file, last).unwrap_or(i64::MAX));
files
}
fn main() {

View File

@ -3,11 +3,7 @@ use requestty::Question;
fn main() {
let order_select = Question::order_select("home_tasks")
.message("Please organize the tasks to be done at home")
.choices(vec![
"Make the bed",
"Clean the dishes",
"Mow the lawn",
])
.choices(vec!["Make the bed", "Clean the dishes", "Mow the lawn"])
.validate(|c, _| {
if c[0].text() == "Make the bed" {
Ok(())
@ -18,4 +14,4 @@ fn main() {
.build();
println!("{:#?}", requestty::prompt_one(order_select));
}
}

View File

@ -1,6 +1,6 @@
[package]
name = "requestty-macro"
version = "0.4.1"
version = "0.5.0"
authors = ["Lutetium Vanadium"]
edition = "2018"
description = "The `questions` macro for `requestty`"

View File

@ -87,9 +87,9 @@ impl Choices {
let content;
syn::bracketed!(content in input);
Ok(Choices::Array(content.parse_terminated(parser)?))
content.parse_terminated(parser).map(Choices::Array)
} else {
Ok(Choices::Expr(input.parse()?))
input.parse().map(Choices::Expr)
}
}
@ -100,6 +100,10 @@ impl Choices {
pub(crate) fn parse_multi_select_choice(input: syn::parse::ParseStream) -> syn::Result<Self> {
Choices::parse_impl(input, parse_multi_select_choice)
}
pub(crate) fn parse_order_select_choice(input: syn::parse::ParseStream) -> syn::Result<Self> {
input.parse().map(Choices::Expr)
}
}
impl From<syn::ExprPath> for Choices {

View File

@ -32,6 +32,7 @@ pub(crate) enum QuestionKind {
RawSelect,
Expand,
MultiSelect,
OrderSelect,
Password,
Editor,
Custom,
@ -48,6 +49,7 @@ impl QuestionKind {
QuestionKind::RawSelect => "raw_select",
QuestionKind::Expand => "expand",
QuestionKind::MultiSelect => "multi_select",
QuestionKind::OrderSelect => "order_select",
QuestionKind::Password => "password",
QuestionKind::Editor => "editor",
QuestionKind::Custom => "custom",
@ -89,6 +91,13 @@ impl QuestionKind {
| BuilderMethods::CHOICES
| BuilderMethods::ON_ESC
}
QuestionKind::OrderSelect => {
BuilderMethods::TRANSFORM
| BuilderMethods::VAL_FIL
| BuilderMethods::LOOP_PAGE_SIZE
| BuilderMethods::CHOICES
| BuilderMethods::ON_ESC
}
QuestionKind::Password => {
BuilderMethods::TRANSFORM
| BuilderMethods::VAL_FIL
@ -128,6 +137,8 @@ impl Parse for QuestionKind {
QuestionKind::Expand
} else if ident == "MultiSelect" {
QuestionKind::MultiSelect
} else if ident == "OrderSelect" {
QuestionKind::OrderSelect
} else if ident == "Password" {
QuestionKind::Password
} else if ident == "Editor" {
@ -265,6 +276,7 @@ impl Parse for Question {
} else if ident == "choices" {
let parser = match kind {
QuestionKind::MultiSelect => Choices::parse_multi_select_choice,
QuestionKind::OrderSelect => Choices::parse_order_select_choice,
_ => Choices::parse_choice,
};

View File

@ -1,6 +1,6 @@
[package]
name = "requestty-ui"
version = "0.4.1"
version = "0.5.0"
authors = ["Lutetium Vanadium"]
edition = "2018"
description = "A widget based terminal ui rendering library."
@ -19,7 +19,7 @@ textwrap = "0.15"
unicode-segmentation = "1.9"
once_cell = "1.12"
crossterm = { version = "0.23", optional = true }
crossterm = { version = "0.25", optional = true }
termion = { version = "1.5", optional = true }
[dev-dependencies]

View File

@ -1,3 +1,5 @@
use std::convert::{TryFrom, TryInto};
use crossterm::event;
use super::EventIterator;
@ -19,14 +21,18 @@ impl EventIterator for CrosstermEvents {
fn next_event(&mut self) -> std::io::Result<super::KeyEvent> {
loop {
if let event::Event::Key(k) = event::read()? {
return Ok(k.into());
if let Ok(k) = k.try_into() {
return Ok(k);
}
}
}
}
}
impl From<event::KeyEvent> for super::KeyEvent {
fn from(event: event::KeyEvent) -> Self {
impl TryFrom<event::KeyEvent> for super::KeyEvent {
type Error = ();
fn try_from(event: event::KeyEvent) -> Result<Self, ()> {
let code = match event.code {
event::KeyCode::Backspace => super::KeyCode::Backspace,
event::KeyCode::Enter => super::KeyCode::Enter,
@ -46,6 +52,7 @@ impl From<event::KeyEvent> for super::KeyEvent {
event::KeyCode::Char(c) => super::KeyCode::Char(c),
event::KeyCode::Null => super::KeyCode::Null,
event::KeyCode::Esc => super::KeyCode::Esc,
_ => return Err(()),
};
let mut modifiers = super::KeyModifiers::empty();
@ -60,6 +67,6 @@ impl From<event::KeyEvent> for super::KeyEvent {
modifiers |= super::KeyModifiers::ALT;
}
super::KeyEvent { code, modifiers }
Ok(super::KeyEvent { code, modifiers })
}
}

View File

@ -42,7 +42,7 @@ pub enum Answer {
/// ListItems will be returned by [`multi_select`] and [`order_select`].
///
/// [`multi_select`]: crate::question::Question::multi_select
/// [`multi_select`]: crate::question::Question::order_select
/// [`order_select`]: crate::question::Question::order_select
ListItems(Vec<ListItem>),
}
@ -215,11 +215,7 @@ impl_from!(Vec<ListItem> => ListItems);
impl From<Vec<OrderSelectItem>> for Answer {
fn from(v: Vec<OrderSelectItem>) -> Self {
Answer::ListItems(
v.into_iter()
.map(|o| o.into())
.collect()
)
Answer::ListItems(v.into_iter().map(|o| o.into()).collect())
}
}
@ -247,6 +243,15 @@ impl<I: Into<String>> From<(usize, I)> for ListItem {
}
}
impl From<OrderSelectItem> for ListItem {
fn from(o: OrderSelectItem) -> Self {
ListItem {
index: o.initial_index,
text: o.text.text,
}
}
}
/// A representation of a [`Choice`] for a particular key.
///
/// It will be returned by [`expand`].

View File

@ -5,7 +5,7 @@
//!
//! # Questions
//!
//! This crate is based on creating [`Question`]s, and then prompting them to the user. There are 10
//! This crate is based on creating [`Question`]s, and then prompting them to the user. There are 11
//! in-built [`Question`]s, but if none of them fit your need, you can [create your own!](#custom-prompts)
//!
//! There are 2 ways of creating [`Question`]s.
@ -178,8 +178,9 @@ use ui::{backend::Backend, events::EventIterator};
/// // used.
/// when,
/// // While most values are generic expressions, if a array literal is passed to
/// // choices, some special syntax applies. Also, unlike other fields, 'choices'
/// // will call `choices_with_default` for `MultiSelect` questions only.
/// // choices, some special syntax applies.
/// // - For `MultiSelect`, default can be specified
/// // - For `OrderSelect`, separators cannot be specified
/// choices: [
/// // By default array entries are taken as `Choice(_)`s.
/// "Choice 1",

View File

@ -131,8 +131,9 @@ where
/// // used.
/// when,
/// // While most values are generic expressions, if a array literal is passed to
/// // choices, some special syntax applies. Also, unlike other fields, 'choices'
/// // will call `choices_with_default` for `MultiSelect` questions only.
/// // choices, some special syntax applies.
/// // - For `MultiSelect`, default can be specified
/// // - For `OrderSelect`, separators cannot be specified
/// choices: [
/// // By default array entries are taken as `Choice(_)`s.
/// "Choice 1",

View File

@ -33,18 +33,31 @@ impl<'a> Default for Editor<'a> {
}
}
#[cfg(unix)]
fn split(command: &str) -> Option<Vec<String>> {
shell_words::split(command).ok()
}
#[cfg(windows)]
fn split(command: &str) -> Option<Vec<String>> {
Some(winsplit::split(command))
}
fn get_editor() -> Command {
Command::new(
env::var_os("VISUAL")
.or_else(|| env::var_os("EDITOR"))
.unwrap_or_else(|| {
if cfg!(windows) {
"notepad".into()
} else {
"vim".into()
}
}),
)
let editor_args = env::var_os("VISUAL")
.or_else(|| env::var_os("EDITOR"))
.and_then(|editor_command| editor_command.to_str().map(split))
.flatten()
.unwrap_or_else(|| {
if cfg!(windows) {
vec!["notepad".into()]
} else {
vec!["vim".into()]
}
});
let mut command = Command::new(&editor_args[0]);
command.args(&editor_args[1..]);
command
}
struct EditorPrompt<'a, 'e> {

View File

@ -18,9 +18,9 @@ macro_rules! impl_filter_builder {
$(#[$meta])+
pub fn filter<F>(mut self, filter: F) -> Self
where
F: FnOnce($t, &crate::Answers) -> $t + 'a,
F: FnOnce($t, &$crate::Answers) -> $t + 'a,
{
self.$inner.filter = crate::question::Filter::Sync(Box::new(filter));
self.$inner.filter = $crate::question::Filter::Sync(Box::new(filter));
self
}
};
@ -56,10 +56,10 @@ macro_rules! impl_auto_complete_builder {
$(#[$meta])+
pub fn auto_complete<F>(mut self, auto_complete: F) -> Self
where
F: FnMut($t, &crate::Answers) -> Completions<$t> + 'a,
F: FnMut($t, &$crate::Answers) -> Completions<$t> + 'a,
{
self.$inner.auto_complete =
crate::question::AutoComplete::Sync(Box::new(auto_complete));
$crate::question::AutoComplete::Sync(Box::new(auto_complete));
self
}
};
@ -69,11 +69,11 @@ macro_rules! impl_auto_complete_builder {
#[macro_export]
macro_rules! impl_validate_builder {
($(#[$meta:meta])+ $t:ty; $inner:ident) => {
crate::impl_validate_builder!($(#[$meta])* impl &$t; $inner Validate);
$crate::impl_validate_builder!($(#[$meta])* impl &$t; $inner Validate);
};
($(#[$meta:meta])+ by val $t:ty; $inner:ident) => {
crate::impl_validate_builder!($(#[$meta])* impl $t; $inner ValidateByVal);
$crate::impl_validate_builder!($(#[$meta])* impl $t; $inner ValidateByVal);
};
// NOTE: the 2 extra lines at the end of each doc comment is intentional -- it makes sure that
@ -93,9 +93,9 @@ macro_rules! impl_validate_builder {
$(#[$meta])*
pub fn validate<F>(mut self, filter: F) -> Self
where
F: FnMut($t, &crate::Answers) -> Result<(), String> + 'a,
F: FnMut($t, &$crate::Answers) -> Result<(), String> + 'a,
{
self.$inner.validate = crate::question::$handler::Sync(Box::new(filter));
self.$inner.validate = $crate::question::$handler::Sync(Box::new(filter));
self
}
};
@ -105,11 +105,11 @@ macro_rules! impl_validate_builder {
#[macro_export]
macro_rules! impl_validate_on_key_builder {
($(#[$meta:meta])+ $t:ty; $inner:ident) => {
crate::impl_validate_on_key_builder!($(#[$meta])* impl &$t; $inner ValidateOnKey);
$crate::impl_validate_on_key_builder!($(#[$meta])* impl &$t; $inner ValidateOnKey);
};
($(#[$meta:meta])+ by val $t:ty; $inner:ident) => {
crate::impl_validate_on_key_builder!($(#[$meta])* impl $t; $inner ValidateOnKeyByVal);
$crate::impl_validate_on_key_builder!($(#[$meta])* impl $t; $inner ValidateOnKeyByVal);
};
// NOTE: the 2 extra lines at the end of each doc comment is intentional -- it makes sure that
@ -133,9 +133,9 @@ macro_rules! impl_validate_on_key_builder {
$(#[$meta])*
pub fn validate_on_key<F>(mut self, filter: F) -> Self
where
F: FnMut($t, &crate::Answers) -> bool + 'a,
F: FnMut($t, &$crate::Answers) -> bool + 'a,
{
self.$inner.validate_on_key = crate::question::$handler::Sync(Box::new(filter));
self.$inner.validate_on_key = $crate::question::$handler::Sync(Box::new(filter));
self
}
};
@ -145,11 +145,11 @@ macro_rules! impl_validate_on_key_builder {
#[macro_export]
macro_rules! impl_transform_builder {
($(#[$meta:meta])+ $t:ty; $inner:ident) => {
crate::impl_transform_builder!($(#[$meta])* impl &$t; $inner Transform);
$crate::impl_transform_builder!($(#[$meta])* impl &$t; $inner Transform);
};
($(#[$meta:meta])+ by val $t:ty; $inner:ident) => {
crate::impl_transform_builder!($(#[$meta])* impl $t; $inner TransformByVal);
$crate::impl_transform_builder!($(#[$meta])* impl $t; $inner TransformByVal);
};
// NOTE: the 2 extra lines at the end of each doc comment is intentional -- it makes sure that
@ -169,9 +169,9 @@ macro_rules! impl_transform_builder {
$(#[$meta])*
pub fn transform<F>(mut self, transform: F) -> Self
where
F: FnOnce($t, &crate::Answers, &mut dyn Backend) -> std::io::Result<()> + 'a,
F: FnOnce($t, &$crate::Answers, &mut dyn Backend) -> std::io::Result<()> + 'a,
{
self.$inner.transform = crate::question::$handler::Sync(Box::new(transform));
self.$inner.transform = $crate::question::$handler::Sync(Box::new(transform));
self
}
};

View File

@ -26,7 +26,7 @@ pub use expand::ExpandBuilder;
pub use input::InputBuilder;
pub use multi_select::MultiSelectBuilder;
pub use number::{FloatBuilder, IntBuilder};
pub use order_select::{OrderSelectBuilder, OrderSelectItem};
pub use order_select::{builder::OrderSelectBuilder, OrderSelectItem};
pub use password::PasswordBuilder;
pub use raw_select::RawSelectBuilder;
pub use select::SelectBuilder;
@ -44,7 +44,7 @@ use options::Options;
/// A `Question` that can be asked.
///
/// There are 11 variants.
/// There are 12 variants.
///
/// - [`input`](Question::input)
/// - [`password`](Question::password)
@ -438,9 +438,8 @@ impl Question<'static> {
///
/// The choices are [`String`]s and can be multiline.
///
/// // TODO : add a gif for OrderSelect
/// <img
/// src="https://raw.githubusercontent.com/lutetium-vanadium/requestty/master/assets/multi-select.gif"
/// src="https://raw.githubusercontent.com/lutetium-vanadium/requestty/master/assets/order-select.gif"
/// style="max-height: 20rem"
/// />
///

View File

@ -52,7 +52,7 @@ impl Int<'_> {
}
fn filter_map(c: char) -> Option<char> {
if c.is_digit(10) || c == '-' || c == '+' {
if c.is_ascii_digit() || c == '-' || c == '+' {
Some(c)
} else {
None

View File

@ -48,7 +48,7 @@ macro_rules! impl_options_builder {
$(#[$message_meta])*
pub fn message<M>(mut self, message: M) -> Self
where
M: Into<crate::question::options::Getter<'a, String>>,
M: Into<$crate::question::options::Getter<'a, String>>,
{
self.opts.message = Some(message.into());
self
@ -68,7 +68,7 @@ macro_rules! impl_options_builder {
$(#[$when_meta])*
pub fn when<W>(mut self, when: W) -> Self
where
W: Into<crate::question::options::Getter<'a, bool>>,
W: Into<$crate::question::options::Getter<'a, bool>>,
{
self.opts.when = when.into();
self
@ -109,7 +109,7 @@ macro_rules! impl_options_builder {
$(#[$on_esc_meta])*
pub fn on_esc<T>(mut self, on_esc: T) -> Self
where
T: Into<crate::question::options::Getter<'a, ui::OnEsc>>,
T: Into<$crate::question::options::Getter<'a, ui::OnEsc>>,
{
self.opts.on_esc = on_esc.into();
self

View File

@ -1,9 +1,7 @@
use ui::backend::Backend;
use ui::widgets::Text;
use crate::{
question::{Options},
};
use crate::question::Options;
use super::{OrderSelect, OrderSelectItem};
@ -11,9 +9,8 @@ use super::{OrderSelect, OrderSelectItem};
///
/// The choices are [`String`]s and can be multiline.
///
/// // TODO : add gif
/// <img
/// src="https://raw.githubusercontent.com/lutetium-vanadium/requestty/master/assets/multi-select.gif"
/// src="https://raw.githubusercontent.com/lutetium-vanadium/requestty/master/assets/order-select.gif"
/// style="max-height: 20rem"
/// />
///
@ -23,7 +20,7 @@ use super::{OrderSelect, OrderSelectItem};
///
/// ```
/// use requestty::Question;
///
///
/// let order_select = Question::order_select("home_tasks")
/// .message("Please organize the tasks to be done at home")
/// .choices(vec![
@ -178,17 +175,18 @@ impl<'a> OrderSelectBuilder<'a> {
{
let len = self.order_select.choices.choices.len();
self.order_select.choices.choices.extend(
choices
.into_iter()
.enumerate()
.map(|(i, c)|
OrderSelectItem {
initial_index:len + i,
text: Text::new(c.into())
}
),
);
self.order_select
.choices
.choices
.extend(
choices
.into_iter()
.enumerate()
.map(|(i, c)| OrderSelectItem {
initial_index: len + i,
text: Text::new(c.into()),
}),
);
self
}
@ -255,7 +253,8 @@ impl<'a> OrderSelectBuilder<'a> {
///
/// [`Question`]: crate::question::Question
pub fn build(mut self) -> crate::question::Question<'a> {
self.order_select.max_index_width = (self.order_select.choices.len() as f64 + 1.0).log10() as usize + 1;
self.order_select.max_index_width =
(self.order_select.choices.len() as f64 + 1.0).log10() as usize + 1;
crate::question::Question::new(
self.opts,

View File

@ -1,5 +1,3 @@
mod builder;
use std::io;
use ui::{
@ -10,13 +8,13 @@ use ui::{
Prompt, Widget,
};
use crate::{Answer, Answers, ListItem};
use super::{
handler::{Filter, Transform, Validate}, choice::SelectList,
choice::SelectList,
handler::{Filter, Transform, Validate},
};
use crate::{Answer, Answers};
pub use builder::OrderSelectBuilder;
pub(super) mod builder;
#[cfg(test)]
mod tests;
@ -38,7 +36,7 @@ pub(super) struct OrderSelect<'a> {
impl<'a> Default for OrderSelect<'a> {
fn default() -> Self {
Self {
Self {
choices: SelectList::new(|_| true),
// can't put
@ -51,7 +49,7 @@ impl<'a> Default for OrderSelect<'a> {
filter: Default::default(),
}
}
}
}
impl widgets::List for OrderSelect<'_> {
fn render_item<B: ui::backend::Backend>(
@ -79,7 +77,7 @@ impl widgets::List for OrderSelect<'_> {
write!(
b,
"{:>width$}. ",
index,
index + 1,
width = self.max_index_width as usize
)?;
@ -120,9 +118,8 @@ impl<'c> OrderSelect<'c> {
answers: &'a Answers,
) -> OrderSelectPrompt<'a, 'c> {
OrderSelectPrompt {
prompt: widgets::Prompt::new(message).with_hint(
"Press <space> to take and place an option",
),
prompt: widgets::Prompt::new(message)
.with_hint("Press <space> to take and place an option"),
select: widgets::Select::new(self),
answers,
}
@ -188,9 +185,7 @@ impl Prompt for OrderSelectPrompt<'_, '_> {
fn finish(self) -> Self::Output {
let OrderSelect {
choices,
filter,
..
choices, filter, ..
} = self.select.into_inner();
let mut c = choices.choices;
@ -230,13 +225,13 @@ impl Widget for OrderSelectPrompt<'_, '_> {
fn handle_key(&mut self, key: ui::events::KeyEvent) -> bool {
let prev_at = self.select.get_at();
if let ui::events::KeyCode::Char(' ') = key.code {
self.select.list.moving = !self.select.list.moving;
} else if self.select.handle_key(key) {
if self.select.list.moving {
let new_at = self.select.get_at();
if prev_at < new_at {
self.select.list.choices.choices[prev_at..=new_at].rotate_left(1);
} else {
@ -246,22 +241,22 @@ impl Widget for OrderSelectPrompt<'_, '_> {
} else {
return false;
}
true
}
}
// =============================================================================
//
//
// =============================================================================
/// The representation of each choice in an [`OrderSelect`].
/// The representation of each choice in an [`OrderSelect`](crate::Question::order_select).
///
/// It is different from [`ListItem`](crate::answer::ListItem) due to an implementation detail.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OrderSelectItem {
initial_index: usize,
text: Text<String>,
pub(crate) initial_index: usize,
pub(crate) text: Text<String>,
}
impl OrderSelectItem {
@ -298,9 +293,3 @@ impl Widget for OrderSelectItem {
self.text.handle_key(key)
}
}
impl Into<ListItem> for OrderSelectItem {
fn into(self) -> ListItem {
ListItem { index: self.initial_index, text: self.text.text }
}
}

View File

@ -1,8 +1,13 @@
use ui::{backend::TestBackend, layout::Layout, events::{KeyCode, KeyEvent}};
use ui::{
backend::TestBackend,
events::{KeyCode, KeyEvent},
layout::Layout,
};
use crate::question::{Question, QuestionKind};
use super::*;
use builder::OrderSelectBuilder;
fn choices(len: usize) -> impl Iterator<Item = String> {
(0..len).map(|choice| choice.to_string())
@ -93,7 +98,7 @@ macro_rules! test_order_select {
layout,
base_layout.with_offset(0, $height).with_line_offset(0)
);
ui::assert_backend_snapshot!(backend);
ui::assert_backend_snapshot!(backend);
assert!(order_select.handle_key(key))
}

View File

@ -199,7 +199,7 @@ impl<'a> RawSelect<'a> {
RawSelectPrompt {
input: widgets::StringInput::with_filter_map(|c| {
if c.is_digit(10) {
if c.is_ascii_digit() {
Some(c)
} else {
None

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✔ order select · 0, 2, 3, 4, 5, 6, 7, 8, 9, 1 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an opti│
on) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✖ message · Skipped │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an opti│
on) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✔ order select · 1: 1, 0: 0, 2: 2, 3: 3, 4: 4, 5: │
5, 6: 6, 7: 7, 8: 8, 9: 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
✔ order select · 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 1 │
 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
✖ Error │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 1 │
│ 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 1 │
│ 2. 0 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 0 │
 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
│ 1. 0 │
 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: tests/helpers/mod.rs
expression: self.backend
---
┌──────────────────────────────────────────────────┐
? order select (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -1,13 +1,10 @@
---
source: src/question/order_select/tests.rs
assertion_line: 117
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 0. 0 │
│ 1. 1 │
│ 2. 2 │
│ 3. 3 │
@ -17,6 +14,7 @@ expression: backend
│ 7. 7 │
│ 8. 8 │
│ 9. 9 │
 10. 0 │
  │
│ │
│ │

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
  │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ 11. 10 │
│ 12. 11 │
│ 13. 12 │
│ 14. 13 │
(Move up and down to reveal more choices) │
  │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -1,15 +1,12 @@
---
source: src/question/order_select/tests.rs
assertion_line: 124
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
│ 18. 18 │
│ 19. 19 │
 0. 0 │
 20. 0 │
│ 1. 1 │
│ 2. 2 │
│ 3. 3 │
@ -21,6 +18,7 @@ expression: backend
│ 9. 9 │
│ 10. 10 │
│ 11. 11 │
│ 12. 12 │
(Move up and down to reveal more choices) │
  │
│ │

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
│ 19. 18 │
│ 20. 19 │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ 11. 10 │
│ 12. 11 │
(Move up and down to reveal more choices) │
  │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
│ 19. 18 │
│ 20. 19 │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ 11. 10 │
│ 12. 11 │
(Move up and down to reveal more choices) │
  │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -0,0 +1,26 @@
---
source: src/question/order_select/tests.rs
expression: backend
---
┌──────────────────────────────────────────────────┐
? message (Press <space> to take and place an│
 option) │
 1. 0 │
│ 2. 1 │
│ 3. 2 │
│ 4. 3 │
│ 5. 4 │
│ 6. 5 │
│ 7. 6 │
│ 8. 7 │
│ 9. 8 │
│ 10. 9 │
│ 11. 10 │
│ 12. 11 │
│ 13. 12 │
│ 14. 13 │
(Move up and down to reveal more choices) │
  │
│ │
│ │
└──────────────────────────────────────────────────┘

View File

@ -86,6 +86,22 @@ fn test_multi_select() {
t.compile_fail("prompt");
}
#[test]
#[ignore = "proc-macro test"]
fn test_order_select() {
let t = Runner::new("order_select");
t.pass("valid");
t.compile_fail("default");
t.compile_fail("separator");
t.compile_fail("validate_on_key");
t.compile_fail("auto_complete");
t.compile_fail("mask");
t.compile_fail("extension");
t.compile_fail("editor");
t.compile_fail("prompt");
}
#[test]
#[ignore = "proc-macro test"]
fn test_confirm() {

View File

@ -0,0 +1,5 @@
fn main() {
requestty::questions![OrderSelect {
auto_complete: todo!()
}];
}

View File

@ -0,0 +1,5 @@
error: option `auto_complete` does not exist for kind `order_select`
--> tests/macros/order_select/auto_complete.rs:3:9
|
3 | auto_complete: todo!()
| ^^^^^^^^^^^^^

View File

@ -0,0 +1,3 @@
fn main() {
requestty::questions![OrderSelect { default: todo!() }];
}

View File

@ -0,0 +1,5 @@
error: option `default` does not exist for kind `order_select`
--> tests/macros/order_select/default.rs:2:41
|
2 | requestty::questions![OrderSelect { default: todo!() }];
| ^^^^^^^

View File

@ -0,0 +1,3 @@
fn main() {
let q = requestty::questions![OrderSelect { editor: todo!() }];
}

View File

@ -0,0 +1,5 @@
error: option `editor` does not exist for kind `order_select`
--> tests/macros/order_select/editor.rs:2:49
|
2 | let q = requestty::questions![OrderSelect { editor: todo!() }];
| ^^^^^^

View File

@ -0,0 +1,3 @@
fn main() {
let q = requestty::questions![OrderSelect { extension: todo!() }];
}

View File

@ -0,0 +1,5 @@
error: option `extension` does not exist for kind `order_select`
--> tests/macros/order_select/extension.rs:2:49
|
2 | let q = requestty::questions![OrderSelect { extension: todo!() }];
| ^^^^^^^^^

View File

@ -0,0 +1,3 @@
fn main() {
let q = requestty::questions![OrderSelect { mask: todo!() }];
}

View File

@ -0,0 +1,5 @@
error: option `mask` does not exist for kind `order_select`
--> tests/macros/order_select/mask.rs:2:49
|
2 | let q = requestty::questions![OrderSelect { mask: todo!() }];
| ^^^^

Some files were not shown because too many files have changed in this diff Show More