Skip to main content

Provides a straightforward way to create command line arguments.

Project description

jarguments

simplifying args jargon

version status downloads

Summary

Provides a straightforward way to create command line arguments.

  • :snake: Supports Python 3.8 and above. Tested on Windows 10.
  • :warning: This project is still in development. Contributions are welcome!
  • :star: The simplest way to show your support is to leave a star!

Contents

Installation

python -m pip install --upgrade jarguments

Usage

There are three steps to using the jarguments library:

  1. Import the jarguments library.

    from jarguments import create, parse
    
  2. Provide your arguments with jarguments' classes.

    # argument parser
    args = parse.JParser(
    
      # boolean argument
      create.JBool('show-text', helpstring='determines whether "text" is shown'),
    
      # integer argument
      create.JInt('number', default=1),
    
      # string argument
      create.JStr('text'),
    )
    
  3. Use the outputs; they're parsed automatically!

    if args.show_text:
      for _ in range(args.number):
        print(args.text)
    

Now it works just like any other command line application.

$ python example.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 example.py --show-text
    error: the following arguments are required: --text
    
  • The --help/-h flag displays help messages:

    $ python example.py -h
    usage: example.py [-h] [--show-text [SHOW_TEXT]] [--number NUMBER] --text [TEXT ...]
    
    options:
      -h, --help            show this help message and exit
      --show-text [SHOW_TEXT]
                            determines whether "text" is shown
      --number NUMBER
      --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.2.0.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

jarguments-0.2.0-py3-none-any.whl (6.6 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