petereon / beaupy

A Python library of interactive CLI elements you have been looking for
https://petereon.github.io/beaupy/
MIT License
181 stars 13 forks source link

documentation idea (no main()) #53

Closed epogrebnyak closed 1 year ago

epogrebnyak commented 1 year ago

Have you though of gettign rid of main in a starter example? Iwthout main people can easily use code right away.

def main():
    """Main."""
    # Confirm a dialog
epogrebnyak commented 1 year ago

Here is asimplfied example I used to start with beaupy

from beaupy import confirm, console, select

names = [
        "Frodo Baggins",
        "Samwise Gamgee",
        "Legolas",
        "Aragorn",
        "[red]Sauron[/red]",
    ]

if confirm("Will you take the ring to Mordor?"):
    console.print("Who are you?")
    name = select(names, cursor="🢧", cursor_style="cyan")
    console.print("Alámenë", name)
petereon commented 1 year ago

This is a good point, if __name__=='__main__' block might be a bit confusing for people who are new to Python, despite being a best practice. I am going to adjust that and remove main in the next release.

petereon commented 1 year ago

Done! Thanks for a suggestion!