Skip to main content

Simple command-line parser.

Project description

This small python package implements a simple object-oriented layer on top of python’s argparse, offering a more intuitive and easier way to build command-line interfaces.

Quick Start

Installing Oi package.

pip install oicli

Usage example

Given the commands bellow:

$ myapp user list
$ myapp user add --name Wilson --email wilson@codeminus.org

The parser would look like this:

import oi

app = oi.App('myapp')
user_cmd = oi.Command(app, 'user')

user_list_cmd = oi.Command(user_cmd, 'list')

user_add_cmd = oi.Command(user_cmd, 'add')
user_add_cmd.add_argument('--name')
user_add_cmd.add_argument('--email')

print(app.parse_args())

Running the application with the code above:

$ myapp user
Namespace(command='user')
$ myapp user list
Namespace(command='user_list')
$ myapp user add --name Wilson --email wilson@codeminus.org
Namespace(command='user_add', email='wilson@codeminus.org', name='Wilson')

Notice the command attribute of the Namespace. It correspond to the name of the command invoked. The sub-command name is appended to its parent command to ensure a unique identifier is created.

What does “Oi” mean? Well… What does it mean to you? Try the wiki.

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

oicli-0.2.3.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file oicli-0.2.3.tar.gz.

File metadata

  • Download URL: oicli-0.2.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for oicli-0.2.3.tar.gz
Algorithm Hash digest
SHA256 d058c03b8d6d9635f1d76ef99952de45358097784a749b393e051b09d2dc8953
MD5 fdc78f902528ee95b1f064ccc0d598fc
BLAKE2b-256 af60f984eb89673b0c243244c57b05062bebeea7e69bd8523226895ba7e54bb1

See more details on using hashes here.

Supported by

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