Closed PhML closed 2 years ago
Oh that is a really good point - @PhML I'd love to merge this as a contribution, any chance you can take a stab at it? Happy to provide pointers and help out
Anyone working a PR for this? I'm willing to take a stab at it if no one is.
I've got a basic implementation working. Question for those interested in this feature: should it work with the qmark
value or not? I think it makes sense that if you're just printing a message, you don't want/need to the qmark
value (that is, print
type would just print message
with style style
and ignore qmark
) but open to feedback.
Python 3.10.5 (main, Jun 23 2022, 17:18:49) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from questionary import prompt
>>> prompt([{"name": "name", "type": "text", "message": "What is your name"},{"name": "printme", "type": "print", "message": "Hello Rhet 🦄", "style": "bold italic fg:darkred", "qmark": True, "when": lambda x: x["name"] == "Rhet"}])
? What is your name Rhet
Hello Rhet 🦄
{'name': 'Rhet'}
>>>
(I tried to do an asciinema recording per the contributor's guide but couldn't figure out how to make it work with my python virtual environment to load the right python)
I think it makes sense that if you're just printing a message, you don't want/need to the
qmark
value (that is,message
with stylestyle
and ignoreqmark
)
I agree with this.
Thanks for working on a PR :)
Nice work 🎉 , do you mind opening a PR?
Yes, I'm working on a PR but I'm reworking the implementation because I feel it's a bit too "hacky" at the moment. I initially wanted to avoid modifying prompt()
so I added a new prompt type that subclasses Question
which just prints without asking so that when prompt calls Question.ask_unsafe()
, everything 'just works'. This is not super intuitive though so I think it would be cleaner to just have prompt()
handle the print. As soon as I get a chance to fix this I'll push a PR!
PR submitted (#244)
Describe the problem
With version
1.10.0
when I want to use both prompt with dictionary andprint
question type, I need to call several prompts and to merge answers:Describe the solution
Adding
print
type to prompt dictionary would resolve the issue:Alternatives considered
No response