InteractiveArgparse
Table of Contents
Installation
To install, run
pip install InteractiveArgparse
Getting Started
You can wrap your existing ArgumentParser with an InteractiveArgumentParser like so:
import argparse
from interactive_argparse import InteractiveArgumentParser
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--name", help="The user's name.")
parser.add_argument("--should_greet", help="Whether or not I should greet the user", action="store_true")
iparser = InteractiveArgumentParser(parser)
args = iparser.parse_args()
print(args)
if __name__ == "__main__":
main()
Running this script without arguments results in interactive prompts like so:
Prompters
InteractiveArgumentParser can be pointed at a completely different interactive flow via its prompter argument: a rich-based terminal prompter (RichPrompter), an auto-generated web form (WebPrompter), or your own custom Prompter subclass.
from interactive_argparse import interactive
@interactive("rich")
def build_parser():
parser = argparse.ArgumentParser()
parser.add_argument("--name", help="The user's name.")
return parser
args = build_parser().parse_args()
See docs/prompters.md for how to use the built-in prompters and how to write your own.
Subcommands
ArgumentParser.add_subparsers() is supported: InteractiveArgumentParser prompts for a subcommand first, then prompts for that subcommand's own arguments.
See docs/subparsers.md for details.
Development
Running tests
To run all tests:
python -m pytest
Contributing
We welcome early adopters and contributors to this project! See the Contributing section for details.
License
This project is open-sourced under the MIT license. See LICENSE for details.
Metadata
Release files for InteractiveArgparse 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| interactiveargparse-0.2.0.tar.gz | 21.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| interactiveargparse-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.7 kB
Release files / interactiveargparse-0.2.0.tar.gz
| Download URL | interactiveargparse-0.2.0.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5f034e85e596c16f83afef07e624f04ae55c1ec0a1b242e74ab4983f079d309
|
|
BLAKE2b-256 checksum How to use checksums |
066f8f75ba7ffc85238710e9aae1eb9bb0406aed6f8f6b90e79560568393de5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / interactiveargparse-0.2.0-py3-none-any.whl
| Download URL | interactiveargparse-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7aeee6616f86e6e698c2fb5688b0bea125efbcbe0d198c20f2c194bd09cfb73
|
|
BLAKE2b-256 checksum How to use checksums |
7476eec994eb40004f2c1a904fe938789fdf0261f024538068fda44e45dd17a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|