A terminal user interface (TUI) for GNU/Linux systems which implements namespaces.
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nscmd-0.1.1.tar.gz.
File metadata
- Download URL: nscmd-0.1.1.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1798ab8946da134bad08a1bc1134bc8e21a88e8b9b5fad7f1400548375e2c742
|
|
| MD5 |
886fd004ce7b9da7f16db2608a6e6921
|
|
| BLAKE2b-256 |
1b93b0f9d4e8433460ea959d7870e409e49b6dc23eb9daf8f4505a0c58e02afa
|
File details
Details for the file nscmd-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nscmd-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cda3b3c085313f88f7351727c366dd9a29b797529f7e6f3f7caa3aafbc4bdc8
|
|
| MD5 |
8d7250ce379b3c357f2183d24e8906ce
|
|
| BLAKE2b-256 |
1ccdaf5b1f3dddaeb15b3796d396c20fb6d65b5d6297a8e7fb6e6a6b8487b8d8
|