{"id":27065632,"url":"https://github.com/poofjunior/inpromptu","last_synced_at":"2025-08-13T17:07:01.926Z","repository":{"id":54944086,"uuid":"281552696","full_name":"Poofjunior/inpromptu","owner":"Poofjunior","description":"a library for automatically inferring interactive prompts","archived":false,"fork":false,"pushed_at":"2024-12-31T07:47:21.000Z","size":86,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-09T20:35:05.036Z","etag":null,"topics":["prompt","prompts","repl","shell"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Poofjunior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-22T02:21:34.000Z","updated_at":"2024-12-31T07:47:24.000Z","dependencies_parsed_at":"2024-12-25T01:28:00.413Z","dependency_job_id":"4e5552f4-a349-4bba-8fd4-76249ed9a8fe","html_url":"https://github.com/Poofjunior/inpromptu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Poofjunior/inpromptu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Poofjunior%2Finpromptu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Poofjunior%2Finpromptu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Poofjunior%2Finpromptu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Poofjunior%2Finpromptu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Poofjunior","download_url":"https://codeload.github.com/Poofjunior/inpromptu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Poofjunior%2Finpromptu/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270278344,"owners_count":24557172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["prompt","prompts","repl","shell"],"created_at":"2025-04-05T18:18:35.457Z","updated_at":"2025-08-13T17:07:01.897Z","avatar_url":"https://github.com/Poofjunior.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Inpromptu\nA library for inferring interactive prompts from object instances.\n\n\n## What Inpromptu Is\nInpromptu is a near-direct replacement for Python's built-in [cmd.py](https://docs.python.org/3/library/cmd.html) utility for rapidly creating *REPL* (read-evaluate-print-loop) interfaces.\nBut instead of rewriting an extra class with special `do_` methods, Inpromptu infers a prompt from the class directly using type hints--and even supports tab completion.\n\nBorn from a need to quickly interact with real-world devices and a frustration from the manual overhead of cmd.py, Inpromptu automatically generates an interactive prompt session by taking advantage of Python's type hinting and introspection capabilities.\nFeatures include\n\n* seamless automatic tab completion using a method's function signature\n  * supports: `bool`, `int`, `float`, `str`, anything that inherits from `Enum`, and `@property`-decorated methods (getter and setters)\n* automatic help generation directly from a method's docstring\n* variable positional (`*args`) and keyword-only (`**kwds`) input\n\nInpromptu also provides a [prompt_toolkit](https://python-prompt-toolkit.readthedocs.io/en/master/)-compatible completer so you can build more complicated prompts while getting all of inpromptu's introspection elements for free.\n\n## What Inpromptu Isn't\nInpromptu creates an interactive prompt. Inpromptu is not:\n* a command line interface generator. See [argparse](https://docs.python.org/3/library/argparse.html), [python-fire](https://github.com/google/python-fire), or [click](https://click.palletsprojects.com/en/7.x/) for that.\n* a api-replacement for cmd.py. There are some differences, mainly the lack of `do_` methods. Have a go at the examples.\n* a GUI with graphical elements. See [magicgui](https://pyapp-kit.github.io/magicgui/) for a project in the same spirit.\n\n## Requirements\n* Python 3.6 or later\n* all methods that will support completion must have all parameters type-hinted\n\n## Installation\nYou can install this latest stable version of this package from PyPI with\n````\npip install inpromptu\n````\n\nOr you can clone this repository and, from within this directory, install inpromptu in *editable* mode with\n````\npip install -e .\n````\n\n## Example Time\n\nStart with a class in file such as test_drive.py.\n```python\nclass TestDrive:\n\n    def __init__(self):\n        \"\"\"initialization!\"\"\"\n        self.vehicle_speed = 0\n\n    honk(self):\n        \"\"\"beep the horn.\"\"\"\n        print(\"Beep!\")\n\n    speed(self):\n        \"\"\"return the vehicle speed.\"\"\"\n        return self.vehicle_speed\n```\n\nCreate a prompt with Inpromptu.\n```python\nfrom inpromptu import Inpromptu\n\nmy_test_drive = TestDrive()\nmy_prompt = Inpromptu(my_test_drive)\nmy_prompt.cmdloop()\n```\n\nRun it!\n```\npython3 test_drive.py\n```\nThis should produce a prompt:\n```\n\u003e\u003e\u003e\n```\nPress **tab** twice to show all your callable attributes.\n```\nhonk            speed\n\u003e\u003e\u003e\n```\n\nGreat! Now let's demo argument completion.\n\nFirst, add a function with [type-hinted annotations](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#functions) for all input arguments (except self or cls).\n```python\nadd_fuel(self, gallons: float = 0, top_off: bool = False):\n    \"\"\"Add fuel in gallons.\"\"\n    pass\n```\nRun it!\n```\npython3 test_drive.py\n```\nStart typing at the prompt\n```\n\u003e\u003e\u003e add_f\n```\nPress tab to complete any function.\n```\n\u003e\u003e\u003e add_fuel\n```\nPut a space between the command and press **tab** twice.\n```\ngallons=\u003cfloat\u003e top_off=\u003cFalse\u003e\n\u003e\u003e\u003e add_fuel \n```\nMagic! At this point you can finish entering the command in many ways.\n```\n\u003e\u003e\u003e add_fuel gallons=10 top_off=False\n```\nOR\n```\n\u003e\u003e\u003e add_fuel 10 False\n```\nOR\n```\n\u003e\u003e\u003e add_fuel 10 top_off=False\n```\nIn other words, arguments can be filled out by name or by position or by a combination of position first, then by name--just like how *args and **kwds behave on normal python functions.\n\nSo what are you waiting for? Why not take it for a test drive? From the example directory, run:\n\n```\npython3 test_drive.py\n```\n\n### Customization\nIt's possible to explicitly specify completions with the `set_completions` method.\n\n```python\nmy_test_drive = TestDrive()\nmy_prompt = Inpromptu(my_test_drive)\nmy_prompt.set_completion_options('add_misc_item', 'stuff',\n                                 ['fridge', 'kelp', 'biscuits',\n                                  'the_one_ring', 'flux_capacitor'])\nmy_prompt.cmdloop()\n```\nNow entering the `add_misc_item` method and double-pressing the **tab** key should produce\n```\n\u003e\u003e\u003e add_misc_item stuff=\nbiscuits        flux_capacitor  fridge          kelp            the_one_ring    \n```\n\n## FAQs\n### Why not just use the Python shell?\nInpromptu is intented to be a minimalistic UI on its own.\nTab-completion and inferring of arguments by type (esp Enums) makes it easier to understand how to invoke the function that strictly by using the shell.\n\n### Is there any way I can tease out the core elements to build my own interface?\nYes. In fact, core elements of Inpromptu can be hooked directly into [Python Prompt Toolkit](https://python-prompt-toolkit.readthedocs.io/en/master/) to provide the same kind of object-based completions with richer prompt features.\nSee the examples folder for some inspiration.\n\n### What's not implemented?\n* The [@overload](https://docs.python.org/3/library/typing.html#typing.overload) operator.\n* functions wrapped in decorators: like `@cache`, `@cached_property` from functools\n  * Note: some cases may work already.\n* Recording a series of commands.\n\n### What's Going to be Implemented Next?\n* Explicit handling of functions wrapped in decorators.\n* Overloading completions for specified functions\n\n## Similar Projects\n* [Kickoff](https://python-kickoff.readthedocs.io/en/latest/#)\n\n## About the Author\nInpromptu was written by someone who used cmd.py one-too-many times.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoofjunior%2Finpromptu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoofjunior%2Finpromptu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoofjunior%2Finpromptu/lists"}