A lightweight verbose argument parser
Project description
Amersham
Amersham: The name of a London Underground station which alliterates with "argument parser"
Motivation
Every CLI application wants two things:
- Sanitized user input
- Descriptive usage and help messages
Amersham implements both with minimal boilerplate.
Quick Start
Install
pip3 install amersham
Import
import sys
from amersham import Parser
Create a parser and command
parser = Parser("app")
@parser.command()
def command(parameter, flag = None):
pass
Run the parser
if __name__ == "__main__":
parser.run(sys.argv[1:])
Run your program
user:~$ python3 app.py --help
usage
app.py [--help] [--flag] PARAMETER
flags
--help -h displays this message
--flag
parameters
PARAMETER string
Advanced Usage
More Descriptive Help Messages
Add some context to our command and arguments
overrides = {
"description": "a command",
"parameter": {
"description": "a parameter",
},
"flag": {
"description": "a flag",
"alias": "f",
}
}
@parser.command(**overrides)
def command(parameter, flag = ""):
pass
And see the results
user:~$ python3 app.py --help
usage
app.py [--help] [--flag] PARAMETER
description
a command
flags
--help -h displays this message
--flag string a flag
parameters
PARAMETER string a parameter
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amersham-1.0.1.tar.gz.
File metadata
- Download URL: amersham-1.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b5b422b619bb35ba54cc4b49befeeef188426cbc592093aba59cd37c44ae70
|
|
| MD5 |
6aa1dc9784792375965e6e0b5716d823
|
|
| BLAKE2b-256 |
c0e5f197a75352253e80cf381d84b4dbdf6bad1acf002c5cb4aa0de3b196e4dd
|
File details
Details for the file amersham-1.0.1-py3-none-any.whl.
File metadata
- Download URL: amersham-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e57c3f8852c4b42c1ac805326ff46c3bd92026f071b63406fc472d13973b4b71
|
|
| MD5 |
d29c96746b755434dce7c0eae3d2e67c
|
|
| BLAKE2b-256 |
8ee63ebbdcdf41b6f69cb7c7cb58be9c4385c3aee4860a821b11a306ee893e3e
|