Skip to main content

No project description provided

Project description


annotation descripters to put closuer on classes and objects to allow argparse to be easy to use

A tool to decorate a python class to create an argparse ready command line application

Here is an example application

#!/usr/bin/env python3

import os,re,sys,json

from Argumental.Argue import Argue

# the argument decorator
args = Argue()

# create a root level argparse argument.
@args.argument(short='v', flag=True)
def verbose():
	detailed output mode
	return False

## simple arg main code
# args.parse()
# print(args.verbose())
## or create a reusable decorated class for the command line

# create a subparser based on the class
@args.command(name="class", single=False) # True to bypass to methods
class MyClass(object):
	My Class

	# add an argparse value as a property, override class attributes
		help='with built in setter and deleter'
	def value(self): return

	# declare the method as a sub parser with method parameters
		help='My Parameter'
		help='test values'
	def myOperation(self, myParameter=None):
		My Operation
		return dict(

if __name__ == '__main__': args.execute()


$ ./ -h

usage: [-h] [-v] {class,args} ...

positional arguments:
  {class,args}   commands
    class        My Class
    args         print the values for the args

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  detailed output mode

sub paser for class

$ ./ class -h

usage: class [-h] [-v VALUE] {method} ...

positional arguments:
  {method}              operations
    method              My Operation

optional arguments:
  -h, --help            show this help message and exit
  -v VALUE, --value VALUE
                        with built in setter and deleter, default=abc123

sub parser for method

$ ./ class method -h

usage: class method [-h] -p PARAMETER

optional arguments:
  -h, --help            show this help message and exit
  -p PARAMETER, --parameter PARAMETER
                        My Parameter

and calling the method

$ ./ class -v myv method -p myp

    "myParameter": "myp",
    "value": "myv"

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Argumental, version 1.13
Filename, size File type Python version Upload date Hashes
Filename, size Argumental-1.13.tar.gz (11.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page