Comments (5)
Yes, it will be a breaking change to support the builder pattern.
preventing re-use and requiring constant re-initialization.
You wouldn't need it. Can you describe more on the differences? How did it used to be and how did you need to change it?
from dialoguer.
I used it like this: let mut confirm = Confirm::new();
which let you initialize Confirm, Input, etc once and set the theme once instead of doing it 50 times. The builder pattern is nice but the prompt_with method shouldn't be part of the builder, but on the variable the builder returns so it can be re-used as many times as needed.
from dialoguer.
Just to make sure I don't misunderstand, I would prefer a more concrete example with code. Please understand that I don't have the full context here compared to you.
from dialoguer.
let theme = ColorfulTheme::default();
// Stable
let mut confirm = Confirm::with_theme(&theme);
if confirm.with_prompt("Question 1").interact().unwrap() {}
if confirm.with_prompt("Question 2").interact().unwrap() {}
if confirm.with_prompt("Question 3").interact().unwrap() {}
// Git
if Confirm::with_theme(&theme)
.with_prompt("Question 1")
.interact()
.unwrap()
{}
if Confirm::with_theme(&theme)
.with_prompt("Question 2")
.interact()
.unwrap()
{}
if Confirm::with_theme(&theme)
.with_prompt("Question 3")
.interact()
.unwrap()
{}
With stable if the prompt becomes too long and rustfmt wraps the lines you can create a prompt variable for the input prompt which only takes 2 lines, with the git code it always takes 4 lines even with the prompt variable to separate the input prompt. It also requires initializing a new Confirm and borrowing the Theme every time, this ends up with the git code taking 6 lines of code (because open and close braces are on new lines) rather than 2-3 for the stable code, and this stacks the more questions you ask.
from dialoguer.
All the prompts are now cloneable so that you can reduce the code's duplicity.
from dialoguer.
Related Issues (20)
- Feature request: alert message with pressing enter as only option
- Add some example pictures to the readme with links to the corresponding file in examples.
- Tab completion doesn't work on windows. HOT 1
- Backspace behavior at the end of line
- Handling Interrupt Signals (e.g., Ctrl+C) in `Select` and Other Dialoguer Actions HOT 4
- Duplicate line when wrapped HOT 1
- feat: support multi line input HOT 1
- [Issue] No visual indecator on selected items on Windows Terminal HOT 1
- Feature request: custom keyboard interactions
- Add support for asynchronous non-blocking I/O.
- Add header and footer options to (Fuzzy)Select (for making borders/tables)
- error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration HOT 2
- Feature: Third option for confirm prompt HOT 2
- `Input` post completion text does not appear if the user uses the default
- Request: add screenshots of what it can do to the README
- Save and restore a wizard flow HOT 1
- FuzzySelect messes up existing formatting
- Wide items in fuzzy select make the prompt disappear
- typos in CHANGELOG: dialouger -> dialoguer
- default and allow_empty
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dialoguer.