Skip to main content

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.

Metadata

Release files for promptx 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for promptx 0.0.7
File Size Uploaded Provenance
promptx-0.0.7.tar.gz 15.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for promptx 0.0.7
File Interpreter ABI Platform
promptx-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 31.8 kB

Release files / promptx-0.0.7.tar.gz

Download URL promptx-0.0.7.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
592555822159f03392d8b2c98464a61cfc9bda326e9a9669571110c8b67fc55d
BLAKE2b-256 checksum
How to use checksums
c5c430b5610c109d1413a1a72bfb692f77014e7c94fa9dfb36c3dfba8c5866b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / promptx-0.0.7-py3-none-any.whl

Download URL promptx-0.0.7-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d2b212a374bd23162f00b63f2c8a38b93ed19d275df665d908fffe5c83a1897
BLAKE2b-256 checksum
How to use checksums
0cbafafea3bb8d76338b0a4581670116424b9de8cb8e096d9a00ac9a318e0fb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for promptx 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page