Argdirective is a python module to detect the first command line argument as subcommand.


Keywords
shell argument directive
License
GPL-3.0-only
Install
pip install argdirective==0.0.11rc1

Documentation

The argdirective project

Argdirective is a simple module which takes the first argument passed to your python script as subcommand and tries to find a directive module based on the basename of the script.

Example: script.py subcommand --arg1 --arg2

Consider the following module:

site-packages
│   ...
└───configmount
    │   mount

as well as the following executable script /bin/configmount

#!/bin/python

import argdirective

if __name__ == "__main__":
	argdirective.generator.run()

As you run configmount mount /mnt/configmount --root /etc in the terminal, argdirective will lookup the configmount package, generate additional arguments via getargs() and finally redirect the arguments to the module mount's main() function. See the configmount project for more details.