Skip to main content

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.Arguments object
  • args is a list of blinkparse.Argument objects
  • commands is a list of blinkparse.Command objects
  • description is a description to show at the top of the help page
  • commandRequired is whether the program requires a command to be passed in
  • noOperands is whether the program is allowed to take operands
  • parse(inputArgs=None)
    • Returns a blinkparse.Arguments object
    • inputArgs is a list of the arguments to parse. This defaults to sys.argv[1:]

Argument(name, shortName=None, takesValue=False, required=False, description=None)

  • name is the argument name used in the long syntax (--myArg, --myArg=myValue)
  • shortName is the argument name used in the long syntax (-a, -a myValue)
  • takesValue is whether the argument takes a input (see above)
  • required makes the blinkparse raise an error if the argument isn't passed in
  • description is 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
  • name is the name of the command
  • args is a list of blinkparse.CommandArgument objects that the command takes
  • CommandArgument(name, options=None, required=True)
    • name is the name of the command argument
    • options is a list of allowed options for the argument (defaults to everything)
    • required makes blinkparse raise an error if the command argument isn't passed in
  • aliases is 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)

Source distribution for blinkparse 0.1.5
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)

Table of built distributions (wheels) for blinkparse 0.1.5
File Interpreter ABI Platform Actions
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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page