Create terminal applications with ease.
Project description
USAGE
Importing termx
from termx import termx as tc
Action to run (function to run when command is executed)
def print_input(msg):
print(msg)
Adding commands
tc.add_command(command='testcommand', arguments=1, cmdinfo="[+] prints whatever u type.", action=print_input)
| command / We set a command name whenever we type it this name will be used to access the function.
| arguments / We input a number of required arguments for a function.
| cmdinfo / What the command does (OPTIONAL).
| action / Function to call when success of this command.
We create a function to get input
def terminal():
while 1:
input_ = input("shell> ")
command = input_.split()
if command:
cmd_result, msg = tc.cmd_result(command=command[0], input_=input_)
/ we use 0 to get the command name
if not cmd_result:
print(msg)
| def terminal()
/ we can create a loop to get input forever to feed the terminal input.
| input_ = input("shell> ")
/ we get constant input to feed termX.
| command = input_.split()
/ this is the full command along with arguments passed, we need to supply this to tc.cmd_result()
| cmd_result, msg = tc.cmd_result(command=command[0], input_=input_)
/ cmd_result is the result of the command meaning if it was executed properly.
- if it did not execute properly it returns false (arguments not supplied etc).
/ msg returns the error msg
/ returns two values which are either 'True' or 'False' and if the command passed the arg check and the error msg if it did not pass.
| if command:
/ We use this in order to prevent no input from passing through.
| if not cmd_result: print(msg)
/ this means if the command result turns out to be false print the error message.
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
termx-0.1.1.tar.gz
(3.2 kB
view details)
Built Distribution
termx-0.1.1-py3-none-any.whl
(3.9 kB
view details)
File details
Details for the file termx-0.1.1.tar.gz
.
File metadata
- Download URL: termx-0.1.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e0e51de50d0fd6400be1ac0747f2fc276150761cd61d5f594971145ac49410e |
|
MD5 | 780bbab055796a7a9064fd5c0465578e |
|
BLAKE2b-256 | a4ed8ab9a9cb1d7c6b6995cfa952c9ef81853effc840f14463d74b8188d70ae7 |
File details
Details for the file termx-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: termx-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2653b7133fbd9239c261571864228da81d14a7ffc2677c1315a9e74fed8639f2 |
|
MD5 | a387b898548277b16131c9cecdcaca9d |
|
BLAKE2b-256 | 9da26d6049bc7a0f3e4a5719802751fdc08e14ca97fc4064c1d42d706db13123 |