This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Commandify

Allows simple creation of Python command line utilities through decorating functions. Builds on the argparse module in the standard library. Optionally uses the argcomplete module to provide command line tab-completion for bash/zsh.

Installation

pip install commandify

Running example and usage

Once commandify has been installed, it can be run with:

commandify_examples --help

commandify_examples code:

#!/usr/bin/env python
# Only required if you want to use argcomplete:
# PYTHON_ARGCOMPLETE_OK
'''Examples of a simple set of functions that use commandify
    usage::

        commandify_examples --help
        commandify_examples <command> --help
        commandify_examples --main-arg=22 <command>
        commandify_examples -m=22 <command>
        commandify_examples cmd_no_args

'''
from commandify import commandify, command, main_command


@main_command(main_arg={'flag': '-m'})
def main(main_arg=345):
    '''Example of how to use commandify
    Main command, called before any other command
    Can be used to set any global variables before any other commands executed.
    usage::

        commandify_examples --help
        commandify_examples --main-arg=22 cmd_no_args
        commandify_examples -m=22 cmd_no_args
        commandify_examples cmd_no_args

    '''
    print(type(main_arg))
    print("Main command: {0}".format(main_arg))


@command
def cmd_no_args():
    '''Simplest command
    usage::

        commandify_examples cmd_no_args

    '''
    print('cmd_no_args called')


@command
def cmd1(name):
    '''Simple command with argument
    usage::

        commandify_examples cmd1 --name=a1
        commandify_examples cmd1 --name a3
        commandify_examples cmd1 --name 'a4'

    '''
    print('cmd1 running')
    print(name)


@command(username={'flag': '-n'})
def cmd2(username, userid):
    '''Command with 2 args and a short flag set for name
    usage::

        commandify_examples cmd2 --username=steve --userid=55
        commandify_examples cmd2 -n=sarah --userid=56

    '''
    print('{0}: {1}'.format(userid, username))


@command(some_arg={'default': 377})
def cmd3(some_arg, arg_with_default='arg_default'):
    '''Command with defaults set in two ways
    first through decorator and second through function arguments.
    usage::

        commandify_examples cmd3
        commandify_examples cmd3 --arg-with-default=default_overridden

    '''
    # Type of some_arg will be int:
    print(type(some_arg))
    print(some_arg, arg_with_default)


@command
def cmd4(some_arg=False):
    '''Command with False bool default
    usage::

        commandify_examples cmd4
        commandify_examples cmd4 --some-arg

    '''
    # Type of some_arg will be bool:
    print(type(some_arg))
    # If it is called specifying --some-arg, it will be True.
    print(some_arg)


@command
def cmd5(some_arg=True):
    '''Command with True bool default
    Command line argument gets turned into negative to handle this.
    usage::

        commandify_examples cmd5
        commandify_examples cmd5 --not-some-arg

    '''
    # Type of some_arg will be bool:
    print(type(some_arg))
    # If it is called without specifying --not-some-arg, it will be True.
    print(some_arg)


@command
def cmd6():
    print('cmd6 called')


if __name__ == '__main__':
    try:
        import argcomplete
        commandify(suppress_warnings=['default_true'], use_argcomplete=True)
    except ImportError:
        commandify(suppress_warnings=['default_true'])
Release History

Release History

0.0.4.10

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
commandify-0.0.4.10-py2-none-any.whl (11.3 kB) Copy SHA256 Checksum SHA256 py2 Wheel May 31, 2015
commandify-0.0.4.10.tar.gz (138.4 kB) Copy SHA256 Checksum SHA256 Source May 31, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting