Example #1
0
import columbo


def user_has_dog(answers: columbo.Answers) -> bool:
    return answers["has_dog"]


interactions = [
    columbo.Confirm("has_dog", "Do you have a dog?", default=True),
    columbo.BasicQuestion(
        "dog_name",
        "What is the name of the dog?",
        should_ask=user_has_dog,
        default="Kaylee",
    ),
    columbo.BasicQuestion(
        "dog_breed",
        "What is the breed of the dog?",
        should_ask=user_has_dog,
        default="Basset Hound",
    ),
]

user_answers = columbo.get_answers(interactions)
print(user_answers)
     default="My Flask App",
 ),
 columbo.BasicQuestion(
     "app_name",
     "What will the package import name be?\nThis will be the name used in python code to import from the module",
     default=_normalize_application_name,
     validator=validate_package_import_name,
 ),
 columbo.BasicQuestion(
     "project_short_description",
     "Provide a short description for the project.",
     default="A flasky app.",
 ),
 columbo.Confirm(
     "use_pipenv",
     "Should this project use pipenv?",
     default=False,
 ),
 columbo.Choice(
     "python_version",
     "Which version of Python will this application use?",
     options=["3.10", "3.9", "3.8", "3.7"],
     default="3.10",
 ),
 columbo.Choice(
     "node_version",
     "Which version of Node will this application use?",
     options=["16", "14", "12"],
     default="16",
 ),
 columbo.Confirm(
Example #3
0
import columbo

interactions = [
    columbo.Echo("Welcome to the Columbo example"),
    columbo.Acknowledge("Press enter to start"),
    columbo.BasicQuestion(
        "user",
        "What is your name?",
        default="Patrick",
    ),
    columbo.BasicQuestion(
        "user_email",
        lambda answers: f"""What email address should be used to contact {answers["user"]}?""",
        default="*****@*****.**",
    ),
    columbo.Choice(
        "mood",
        "How are you feeling today?",
        options=["happy", "sad", "sleepy", "confused"],
        default="happy",
    ),
    columbo.Confirm("likes_dogs", "Do you like dogs?", default=True),
]

answers = columbo.get_answers(interactions)
print(answers)
interactions = [
    columbo.Echo(
        "You wake up in a room that you do not recognize. "
        "In the dim light, you can see a large door to the left and a small door to the right."
    ),
    columbo.Choice(
        "which_door",
        "Which door do you walk through?",
        options=["left", "right"],
        default="left",
    ),
    columbo.Confirm(
        "has_key",
        "You step into a short hallway and the door closes behind you, refusing to open again. "
        "As you walk down the hallway, there is a small side table with a key on it.\n"
        "Do you pick up the key before going through the door at the other end?",
        should_ask=went_left,
        default=True,
    ),
    columbo.Confirm(
        "has_hammer",
        "You step into smaller room and the door closes behind, refusing to open again. "
        "The room has a single door on the opposite side of the room and a work bench with a hammer on it.\n"
        "Do you pick up the hammer before going through the door at the other side?",
        should_ask=went_right,
        default=True,
    ),
    columbo.Echo(
        "You enter a small courtyard with high walls. There is an archway that would allow you to go free, "
        "but the gate is locked."
    ),