Skip to main content

The smartest command line arguments parser in the world

Project description

Installation

If you are lazy, just perform

$ pip install plac

which will install the module on your system.

If you prefer to install the full distribution from source, including the documentation, download the tarball, unpack it and run

$ python setup.py install

in the main directory, possibly as superuser.

Testing

Run

$ python doc/test_plac.py

You will see several apparent errors, but this is right, since the tests are checking for several error conditions. The important thing is that you get at the a line like

Executed XX tests OK

Quickstart

Here is a script that does some processing on a database table:

# updatedb.py
from datetime import datetime

def main(dsn, table='product', today=datetime.today()):
    "Do something on the database"
    print(dsn, table, today)

if __name__ == '__main__':
    import plac; plac.call(main)

Here is the help message automatically generated by plac:

$ python updatedb.py -h
usage: updatedb.py [-h] dsn [table] [today]

Do something on the database

positional arguments:
  dsn
  table       [product]
  today       [2019-07-28 07:18:20.054708]

optional arguments:
  -h, --help  show this help message and exit

Nevertheless to say, plac can do a lot more, up to the creation of domain-specific languages(!)

Documentation

It is hosted here: http://micheles.github.io/plac

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

plac-1.3.0.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

plac-1.3.0-py2.py3-none-any.whl (21.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file plac-1.3.0.tar.gz.

File metadata

  • Download URL: plac-1.3.0.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for plac-1.3.0.tar.gz
Algorithm Hash digest
SHA256 2e6422d966ca2cbe30353ad13f1c44fddfa71f8445fb54fff0169d3c982101be
MD5 10e2232a9f938e830920ab94712194a5
BLAKE2b-256 7cc0404e96279ab563a98ca9fe9b7e1dfdd06e3f5ef26af965d62f706385c3bf

See more details on using hashes here.

File details

Details for the file plac-1.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: plac-1.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for plac-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 25c70052cbc734c43b3c93e9c1e7d5f3c86bb88593a4b8efa8de51e58cb7612d
MD5 20f3e553ab8e90c85523b2f0bf48b801
BLAKE2b-256 2097fb22b3f2a81a9e70a417af942aa47b575f794352b30b2be3183c5aef6d70

See more details on using hashes here.

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