promptx


Namepromptx JSON
Version 0.0.7 PyPI version JSON
download
home_page
SummaryFlexible prompt wrapper for dmenu, fzf, and rofi.
upload_time2023-06-09 01:06:24
maintainer
docs_urlNone
author
requires_python
licenseGNU General Public License v3 (GPLv3)
keywords dmenu fzf rofi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

``` python
>>> p = PromptX("dmenu")
```

With default args:

``` python
>>> 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:

``` python
>>> 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`.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "promptx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "dmenu,fzf,rofi",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/c5/c4/30b5610c109d1413a1a72bfb692f77014e7c94fa9dfb36c3dfba8c5866b8/promptx-0.0.7.tar.gz",
    "platform": null,
    "description": "# PromptX\n\nWhether you use dmenu, fzf, or rofi, PromptX gives you complete access\nto your favorite prompt program. As simple or complex as you like the\nchoice is yours.\n\n## Installation\n\nThe usual way:\n\n`pip install promptx`\n\nRequires python3\n\n# Usage\n\n## Initialization\n\nWithout default args:\n\n``` python\n>>> p = PromptX(\"dmenu\")\n```\n\nWith default args:\n\n``` python\n>>> p = PromptX(prompt_cmd=\"dmenu\", default_args=\"-l 20 -i\")\n```\n\nWhat's the difference?\n\nWell, if you initialize the `PromptX` object with default args they get\nincluded every time you use the `ask()` method. This is nice if you\nalways want your prompt to look a certain way despite the question.\n\n## p.ask()\n\nAt it's most basic:\n\n``` python\n>>> choices = [ \"1\", \"2\", \"3\" ]\n>>> response = p.ask(choices)\n>>> print(response)\n'1'\n```\n\nBut there are some additional arguments that `ask()` takes. Here they\nare in positional order.\n\n### options(List)\n\nA list of options to present the user with. Not optional.\n\n### prompt(Optional\\[str\\])\n\nThe prompt to use when querying the user. The necessary flag will get\nautomatically added based on the prompt command used to initialize\n`PromptX`.\n\n### additional_args(Optional\\[str\\])\n\nAdd additional arguments to the prompt command. Any additional arguments\nwill get added before the prompt flag. These arguments must be a string.\nThey will be appropriately split, just provide them as you would from\nthe command line.\n\n### select(Optional\\[str\\])\n\nUser's may select multiple answers in any of the three supported prompt\ncommands. The default is to return the first selection they made. Here\nare the options to change this behavior and the return type of `ask()`:\n\n- \"first\": Default Use \"first\" if you want the first option the user\n  selected. Returns a string.\n- \"last\": Use \"last\" if you want the last option the user selected.\n  Returns a string.\n- \"all\": Use \"all\" if you want all options the user selected. Returns a\n  list of all selected options.\n\n### deliminator(Optional\\[str\\])\n\nDefault is \"\". This is the deliminator to use when joining your list of\noptions.\n\n## p.add_args()\n\nIf you don't like that ask requires a string to add additional args then\nuse this method with a list.\n\n### additional_args(List):\n\nThese args will get added to the `PromptX` object. By default these\narguments are not sticky, meaning they do not change the default args\nthat the object got initialized with.\n\n### default_args(Optional\\[bool\\])\n\nIf you want these arguments to get added to the default args then set\nthis to `True`.\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 (GPLv3)",
    "summary": "Flexible prompt wrapper for dmenu, fzf, and rofi.",
    "version": "0.0.7",
    "project_urls": {
        "repository": "https://codeberg.org/johndovern/promptx"
    },
    "split_keywords": [
        "dmenu",
        "fzf",
        "rofi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0cbafafea3bb8d76338b0a4581670116424b9de8cb8e096d9a00ac9a318e0fb2",
                "md5": "bb4a8f2371c6f995ed34562366ff6499",
                "sha256": "7d2b212a374bd23162f00b63f2c8a38b93ed19d275df665d908fffe5c83a1897"
            },
            "downloads": -1,
            "filename": "promptx-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bb4a8f2371c6f995ed34562366ff6499",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16288,
            "upload_time": "2023-06-09T01:06:23",
            "upload_time_iso_8601": "2023-06-09T01:06:23.253253Z",
            "url": "https://files.pythonhosted.org/packages/0c/ba/fafea3bb8d76338b0a4581670116424b9de8cb8e096d9a00ac9a318e0fb2/promptx-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c5c430b5610c109d1413a1a72bfb692f77014e7c94fa9dfb36c3dfba8c5866b8",
                "md5": "2ac748f66e964183d181feed121a4541",
                "sha256": "592555822159f03392d8b2c98464a61cfc9bda326e9a9669571110c8b67fc55d"
            },
            "downloads": -1,
            "filename": "promptx-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "2ac748f66e964183d181feed121a4541",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15523,
            "upload_time": "2023-06-09T01:06:24",
            "upload_time_iso_8601": "2023-06-09T01:06:24.404964Z",
            "url": "https://files.pythonhosted.org/packages/c5/c4/30b5610c109d1413a1a72bfb692f77014e7c94fa9dfb36c3dfba8c5866b8/promptx-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-09 01:06:24",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": true,
    "codeberg_user": "johndovern",
    "codeberg_project": "promptx",
    "lcname": "promptx"
}
        
Elapsed time: 0.07350s