BlinkParse
A python library for parsing command line arguments
Installation
pip install blinkparse
Usage
Parser(args=[], commands=[], description='', commandRequired=False, noOperands=False)
- Returns a
blinkparse.Argumentsobject argsis a list ofblinkparse.Argumentobjectscommandsis a list ofblinkparse.Commandobjectsdescriptionis a description to show at the top of the help pagecommandRequiredis whether the program requires a command to be passed innoOperandsis whether the program is allowed to take operandsparse(inputArgs=None)- Returns a
blinkparse.Argumentsobject inputArgsis a list of the arguments to parse. This defaults tosys.argv[1:]
- Returns a
Argument(name, shortName=None, takesValue=False, required=False, description=None)
nameis the argument name used in the long syntax (--myArg,--myArg=myValue)shortNameis the argument name used in the long syntax (-a,-a myValue)takesValueis whether the argument takes a input (see above)requiredmakes the blinkparse raise an error if the argument isn't passed indescriptionis a description to show in the help page
Command(name, args=[], aliases=[])
- Usage
Command('hello', [CommandArgument('person'), CommandArgument('gender', required=False, options=['male', 'female', 'other])], 'h')$ python3 example.py hello jered$ python3 example.py hello joe male
nameis the name of the commandargsis a list ofblinkparse.CommandArgumentobjects that the command takesCommandArgument(name, options=None, required=True)nameis the name of the command argumentoptionsis a list of allowed options for the argument (defaults to everything)requiredmakes blinkparse raise an error if the command argument isn't passed in
aliasesis a list of other names for the command
Full example
from blinkparse import *
args = Parser(
args=[
Argument('save', 's', description='Save the program output'),
],
commands=[
Command('hello', [
CommandArgument('person'),
CommandArgument('gender', required=False, options=['male', 'female', 'other'])
]),
Command('bye', [
CommandArgument('person')
])
],
description='''
hello.py
A simple demo of blinkparse
''',
commandRequired=True
).parse()
if args.command == 'hello':
output = 'Hello ' + args.commandArgs['person']
if 'gender' in args.commandArgs:
output += ', you are ' + args.commandArgs['gender']
else:
output = 'Bye ' + args.commandArgs['person']
if 'save' in args.args:
with open('hello.txt', 'w') as outputFile:
outputFile.write(output)
else:
print(output)
Metadata
Release files for blinkparse 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blinkparse-0.1.5.tar.gz | 3.9 kB | Without provenance | Details for blinkparse-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blinkparse-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for blinkparse-0.1.5-py3-none-any.whl |
Total release size: 21.3 kB
Release files / blinkparse-0.1.5.tar.gz
| Download URL | blinkparse-0.1.5.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81cc224c38e452aa61f927baf568610dbaf949089fe9f649151d33d687b6b271
|
|
BLAKE2b-256 checksum How to use checksums |
a1616be490345e7d6e40674f098a7e3bb919b034cf33f5ec922cb9409cd826e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
|
Release files / blinkparse-0.1.5-py3-none-any.whl
| Download URL | blinkparse-0.1.5-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7463ffb673a3ecc2d93b7e610b29209d3831125359c0916c753c925d25a456e9
|
|
BLAKE2b-256 checksum How to use checksums |
c183c1e33c605202cc4bf01a2559a50584d45b0103123fc3a8e858873009043a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
|
Security for blinkparse 0.1.5
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.