Skip to main content

Make custom terminal commands in python.

Project description

TermCmds module

Make custom terminal commands in python.

how to make a basic command

example.py:

import TermCmds

cmd = TermCmds.Command()

@cmd.main_command
def main(args, kwargs, options):
    print(args)
    print(kwargs)
    print(options)

@cmd.command("subcommand")
def subcommand(args, kwargs, options):
    print("subcommand")
    print(args)
    print(kwargs)
    print(options)

if __name__ == "__main__":
    cmd.run()

python example.py a b -k v --o outputs:

["a", "b"]
{"k": "v"}
["o"]

python example.py subcommand c d -key value --option outputs:

subcommand
["c", "d"]
{"key": "value"}
["option"]

documentation

TermCmds.Command() is the class for the command
@cmd.main_command is the main command for .. args kwars options
@cmd.command(name) is the function link for .. name args kwargs options
args is a list of values that are not kwargs or options
kwargs is a dictionary of keys and values -key value
options is a list of options --option

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

TermCmds-0.0.3.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

TermCmds-0.0.3-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

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