Skip to main content

pytcm - Python Terminal Commands Manager

Project description

pytcm

A Python Terminal Commands Manager

Installation

$ pip install pytcm

Usage

Using execute directly

import pytcm

binary = 'python'
opts = [
    pytcm.Flag('--version', True)
]

result = pytcm.execute(binary, opts)

print(result.out)  # "Python 3.9.7"
print(result.err)  # ""
print(result.returncode)  # 0

Using a Command object that holds the context

import pytcm

binary = 'python'
opts = [
    pytcm.Flag('--version', True)
]

cmd = pytcm.Command(binary, opts)
cmd.execute()

print(cmd.out)  # "Python 3.9.7"
print(cmd.err)  # ""
print(cmd.returncode)  # 0

Options

Flag

A boolean option

import pytcm

flag = pytcm.Flag("--verbose", True)
opt = flag.parse()

print(opt)  # "--verbose"

Explicit

An option with an equal sign

import pytcm

explicit = pytcm.Explicit("--age", 12)
opt = explicit.parse()

print(opt)  # "--age=12"

Implicit

An option separated by a space character

import pytcm

implicit = pytcm.Implicit("--age", 12)
opt = implicit.parse()

print(opt)  # "--age 12"

Positional

A simple inline option

import pytcm

positional = pytcm.Positional("test.txt")
opt = positional.parse()

print(opt)  # "test.txt"

Contributing

Thank you for considering making pytcm better.

Please refer to docs.

Change Log

See CHANGELOG

License

MIT

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

pytcm-0.5.6.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

pytcm-0.5.6-py3-none-any.whl (5.2 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