bchao1 / bullet

🚅 Interactive prompts made simple. Build a prompt like stacking blocks.
https://pypi.org/project/bullet/
MIT License
3.55k stars 113 forks source link

feature request: field name for prompts #40

Open woile opened 5 years ago

woile commented 5 years ago

Hey first of all, thanks for the library, it's really simple and beautiful.

I was wondering if it would be possible to have something like this:

from bullet import Bullet
cli = Bullet(
    prompt = "Choose from the items below: ", 
    choices = ["first item", "second item", "third item"], 
    field_name="item_name")
result = cli.launch()
print(dict(result))

Current output

{
    "Choose from the items below: ": "first item"
}

Expected output

{
    "item_name: ": "first item"
}

Sorry if it's already there, but I haven't seen it in the source code.

The idea would be to make it a drop-in replacement for other libraries doing the same thing. https://github.com/tmbo/questionary https://github.com/finklabs/whaaaaat https://github.com/CITGuru/PyInquirer

Thanks!

fernando-mc commented 4 years ago

@Mckinsey666 love the library. I also think this would be a useful addition to allow you to automatically structure the output in a way that works for whatever it gets sent off to.