Skip to content

phoenixr-codes/aprompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aprompt - Advanced Prompt

Why use input() when you can go advanced?

aprompt lets you prompt users in a neat way. It comes with a UI system and everything is customizable!

Demonstration

PyPI Documentation Status Code style: black PyPI - Downloads GitHub License GitHub Repo Stars GitHub Forks

Features

  • ✅ Large set of built-in prompts.
  • ✅ Custom prompts
  • ✅ Custom themes
  • ✅ Drop-in replacement for argparse
  • ✅ Test API

Available Prompts

While it is easily possible to create custom prompts, aprompt comes with a lot of useful prompts.

  • Text
  • Integer
  • Confirmation
  • PIN Code
  • Sort
  • Choice
  • Multiple Choice
  • Path
  • Datetime
  • Date
  • Time

Unchecked prompts are planned for the future

Basic Usage

from aprompt import prompt
from aprompt.prompts import choice

languages: list[str] = prompt(
    "In what languages can you code in?",
    choice(
        "c",
        "c++",
        "erlang",
        "fortran",
        "haskell",
        "javascript",
        "nim",
        "python",
        "ruby",
        "rust",
        "typescript",
        multiple=True
    )
)

# ... do something with `languages` ...

Test API

aprompt provides the attribute test_with for the main prompt wrapper to test the result for a predefined sequence of keys.

def test_confirm() -> None:
    assert prompt("", confirm(), test_with=iter("y"))
    assert not prompt("", confirm(), test_with=iter("n"))

Links

TODO

  • add path prompt (as extension) and document it
  • turn matches into if-elses
  • add demo file and add a GIF of it to the README (instead of only the choice variant)
  • add GIFs to all prompt engines in docs
  • turn simple formatter into a class
  • add logo