nscmd
A terminal user interface (TUI) Python library utilizing inheritance to create namespaces for command execution. The project stemmed from a large refactoring of the cmd library, and eventually led to building an entirely separate library for the sake of design and code cleanliness.
This library currently is only targeted at GNU/Linux platforms due to its use of the readline library for several major features.
Features
- Namespaces
- Built-in help via docstrings
- Command history
- Tab complete
- Clear terminal
- Multi-file interpreter
Example
In a file called bar.py:
from foo import FooInterpreter
class BarInterpreter(FooInterpreter):
name = 'bar'
def do_helloworld(self, args):
return "Hello, bar!"
In a file called foo.py:
import nscmd
class FooInterpreter(nscmd.SubInterpreter):
name = 'foo'
def do_helloworld(self, args):
"""prints Hello, foo!"""
return "Hello, foo!"
if __name__ == "__main__":
# JIT imports allow for multi-file interpreters
from bar import BarInterpreter
# run commands from a list...
cmds = ["main foo","helloworld","main foo bar helloworld"]
m = nscmd.MainInterpreter(cmd_in=cmds)
m.run()
# ... and get the results in a list!
print(nscmd.outqueue)
# ... or use files for input and output
m = nscmd.MainInterpreter(
cmd_in="example_cmds.txt",
outfile="example_output.txt"
)
m.run()
# Use a string!
cmdstr = "main foo\nhelloworld\nmain foo bar helloworld\n"
m = nscmd.MainInterpreter(
cmd_in=cmdstr
)
m.run()
print(nscmd.outqueue)
# or run as a standard TUI
m = nscmd.MainInterpreter()
m.tui()
# no matter what method you use, you can still access
# the output as a list. It resets on each instantiation.
print(nscmd.outqueue)
Metadata
Release files for nscmd 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nscmd-0.1.1.tar.gz | 22.2 kB | Without provenance | Details for nscmd-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nscmd-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for nscmd-0.1.1-py3-none-any.whl |
Total release size: 43.5 kB
Release files / nscmd-0.1.1.tar.gz
| Download URL | nscmd-0.1.1.tar.gz |
|---|---|
| Size | 22.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1798ab8946da134bad08a1bc1134bc8e21a88e8b9b5fad7f1400548375e2c742
|
|
BLAKE2b-256 checksum How to use checksums |
1b93b0f9d4e8433460ea959d7870e409e49b6dc23eb9daf8f4505a0c58e02afa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / nscmd-0.1.1-py3-none-any.whl
| Download URL | nscmd-0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cda3b3c085313f88f7351727c366dd9a29b797529f7e6f3f7caa3aafbc4bdc8
|
|
BLAKE2b-256 checksum How to use checksums |
1ccdaf5b1f3dddaeb15b3796d396c20fb6d65b5d6297a8e7fb6e6a6b8487b8d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for nscmd 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.