Skip to main content

Born Again Command Line Interface.

Project description

bacli

Born Again Command Line Interface.

Bacli is a module that wraps the command line argument parsing functionality of argparse for ease of use. Any Python function can be transformed into an entry point for the program. Simply add the command decorator, and you will be able to call the function directly from the command line (with parameters, documentation and correct types!).

Usage

""" example.py: This file serves as a demonstration of the bacli functionality. """

import bacli

with bacli.cli(__doc__) as cli:

    @cli.command
    def run():
        """ Run the model. """
        print("Running")


    @cli.command
    def train(iterations: int, batch_size: int=32):
        """ Train the model. """
        print("Training model")
        print("{} iterations".format(iterations))
        print("batch size of {}".format(batch_size))

It can then be used as follows:

> python example.py -h
usage: example.py [-h] subcommand ...

example.py: This file serves as a demonstration of the bacli functionality.

positional arguments:
  subcommand  Select one of the following subcommands:
    run       Run the model.
    train     Train the model.

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

> python example.py run
Running

> python example.py train -h
usage: example.py train [-h] [--batch_size BATCH_SIZE] iterations

Train the model.

positional arguments:
  iterations            type: int

optional arguments:
  -h, --help            show this help message and exit
  --batch_size BATCH_SIZE
                        type: int, default=32

> python example.py train 10 --batch_size 64
Training model
10 iterations
batch size of 64

Upcoming Features

  • Support for variable arguments (*args and **kwargs)
  • Support documentation of parameters
  • Support aliases of parameters (maybe use first leter as shortcut)

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

bacli-1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

bacli-1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file bacli-1.0.tar.gz.

File metadata

  • Download URL: bacli-1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.19.5 PyPy/5.10.1

File hashes

Hashes for bacli-1.0.tar.gz
Algorithm Hash digest
SHA256 80d2dd93845a5a2c1fdf8972fb6782efba61a9118f71bbedb2cac225bbf86bf6
MD5 11436d67d8e83b7182e1b6b00af9a046
BLAKE2b-256 6d88a971b54e244d8e2b52215ef6eb41ad0d5fa5d859cf9b38bd9f5ccb4df2dc

See more details on using hashes here.

File details

Details for the file bacli-1.0-py3-none-any.whl.

File metadata

  • Download URL: bacli-1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.19.5 PyPy/5.10.1

File hashes

Hashes for bacli-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b468405fa332ca38d384d359d7e9a626a40cde7211209d32c945116b7801d77
MD5 ad3d17c56f1732bc9a3cd512dedcde10
BLAKE2b-256 e3b195ea1558c14258c2474373077d3fd2fe8783d5cc621736d15fef902882a8

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