Skip to main content

Providing a straightforward way to create command-line arguments.

Project description

jarguments

simplifying args jargon

publish status latest release

Summary

Providing a straightforward way to create command-line arguments.

Works on Python 3.6 and above. Tested on Windows 10.

Contents

Installation

git clone https://github.com/silvncr/jarguments.git
cd jarguments
python setup.py install

Usage

Library

There are three steps to using the jarguments library:

  1. Import the jarguments library.

    from jarguments import *
    
  2. Provide your arguments with jarguments' classes.

    args = JParser(
      JBool('show_text', help='determines whether "text" is shown'),
      JStr('text'),
    )
    
  3. Use your outputs; they are parsed automatically.

    if args.show_text:
      print(args.text)
    

Command-line

  • Now you can run your script with arguments:

    $ python script.py --show_text --text "hello world"
    hello world
    
  • Arguments without a default value are required. If you don't provide them, the script will raise an error:

    $ python script.py --show_text
    error: the following arguments are required: --text
    
  • If you want to see help messages, run your script with the -h or --help flag:

    $ python script.py -h
    usage: script.py [-h] [--show_text] --text TEXT
    
    options:
      -h, --help            show this help message and exit   
      --show_text [SHOW_TEXT]
                            determines whether "text" is shown
      --text TEXT
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jarguments-0.0.1.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

jarguments-0.0.1-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page