Skip to main content

Flexible prompt wrapper for dmenu, fzf, and rofi.

Project description

PromptX

Whether you use dmenu, fzf, or rofi, PromptX gives you complete access to your favorite prompt program. As simple or complex as you like the choice is yours.

Installation

The usual way:

pip install promptx

Requires python3

Usage

Initialization

Without default args:

>>> p = PromptX("dmenu")

With default args:

>>> p = PromptX(prompt_cmd="dmenu", default_args="-l 20 -i")

What's the difference?

Well, if you initialize the PromptX object with default args they get included every time you use the ask() method. This is nice if you always want your prompt to look a certain way despite the question.

p.ask()

At it's most basic:

>>> choices = [ "1", "2", "3" ]
>>> response = p.ask(choices)
>>> print(response)
'1'

But there are some additional arguments that ask() takes. Here they are in positional order.

options(List)

A list of options to present the user with. Not optional.

prompt(Optional[str])

The prompt to use when querying the user. The necessary flag will get automatically added based on the prompt command used to initialize PromptX.

additional_args(Optional[str])

Add additional arguments to the prompt command. Any additional arguments will get added before the prompt flag. These arguments must be a string. They will be appropriately split, just provide them as you would from the command line.

select(Optional[str])

User's may select multiple answers in any of the three supported prompt commands. The default is to return the first selection they made. Here are the options to change this behavior and the return type of ask():

  • "first": Default Use "first" if you want the first option the user selected. Returns a string.
  • "last": Use "last" if you want the last option the user selected. Returns a string.
  • "all": Use "all" if you want all options the user selected. Returns a list of all selected options.

deliminator(Optional[str])

Default is "". This is the deliminator to use when joining your list of options.

p.add_args()

If you don't like that ask requires a string to add additional args then use this method with a list.

additional_args(List):

These args will get added to the PromptX object. By default these arguments are not sticky, meaning they do not change the default args that the object got initialized with.

default_args(Optional[bool])

If you want these arguments to get added to the default args then set this to True.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptx-0.0.7.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

promptx-0.0.7-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file promptx-0.0.7.tar.gz.

File metadata

  • Download URL: promptx-0.0.7.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for promptx-0.0.7.tar.gz
Algorithm Hash digest
SHA256 592555822159f03392d8b2c98464a61cfc9bda326e9a9669571110c8b67fc55d
MD5 2ac748f66e964183d181feed121a4541
BLAKE2b-256 c5c430b5610c109d1413a1a72bfb692f77014e7c94fa9dfb36c3dfba8c5866b8

See more details on using hashes here.

File details

Details for the file promptx-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: promptx-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for promptx-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7d2b212a374bd23162f00b63f2c8a38b93ed19d275df665d908fffe5c83a1897
MD5 bb4a8f2371c6f995ed34562366ff6499
BLAKE2b-256 0cbafafea3bb8d76338b0a4581670116424b9de8cb8e096d9a00ac9a318e0fb2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page