Callixir
A small and convenient tool for implementing command execution in any application. Suitable for a console application or a social media bot.
Its principle of operation is simple: the user sends a string containing the command name and its arguments, if required. The next step is to execute the corresponding method based on this string.
Developed and tested on Python version 3.12. Support for other, later versions has not been addressed yet.
Example
from callixir import SimpleShell
shell = SimpleShell()
@shell.reg("echo")
def cmdEcho(arg: str):
return f"Echo {arg}"
@shell.reg("sum")
def сmdSum(a: int, b: int):
return a + b
@shell.reg("log")
def cmdLog(*args: str):
return ", ".join(args)
result = shell.execute("echo Hello_World!")
print(result.result) # Echo Hello_World!
result = shell.execute("sum 1 2")
print(result.result) # 3
result = shell.execute("log 1 2 Hi 10 J 100 \"many words in one\" 999 71")
print(result.result) # 1, 2, Hi, 10, J, 100, many words in one, 999, 71
Installing
Install Callixir via pip:
pip install callixir
Features
- Convenient handling of arguments, they correspond to the signature of the arguments in the method;
- Support for asynchronous commands;
- Support for named arguments.
Async example
from callixir import AsyncSimpleShell
import asyncio
shell = AsyncSimpleShell()
@shell.reg("echo")
async def cmdEcho(arg: str):
return f"Echo {arg}"
@shell.reg("sum")
async def сmdSum(a: int, b: int):
return a + b
@shell.reg("log")
async def cmdLog(*args: str):
return ", ".join(args)
async def main():
result = await shell.execute("echo Hello_World!")
print(result.result) # Echo Hello_World!
result = await shell.execute("sum 1 4")
print(result.result) # 5
result = await shell.execute("log nova prospekt \"Async cmd\"")
print(result.result) # nova, prospekt, Async cmd
asyncio.run(main())
Named arguments
The handler can work with function's named arguments (**kwargs). Furthermore, the same arguments undergo data type conversion for example, if the annotation is int, then all kwargs arguments will be converted to int.
A named argument can be specified in the string in two ways: --argument_name=value, --argument_name value. Values can also be enclosed in double quotes: --argument_name "multiple values".
Example
from callixir import SimpleShell
shell = SimpleShell()
@shell.reg("info")
def cmdInfo(**kwargs: str):
data = []
for key, value in kwargs.items():
data.append(f"key = {key}\tvalue = {value}")
return "\n".join(data)
@shell.reg("calc")
def cmdCalc(a: float, b: float, **kwargs: str):
action = kwargs.get("action", "+")
if action == "+": return a+b
elif action == "-": return a-b
elif action == "*": return a * b
elif action == "/": return a / b
else: return "Incorrect type of action"
def main():
result = shell.execute("info --arg1=value1 --arg2 value2 --apple red --datetime=\"03.11.2025 15:31\"")
print(result.result)
'''
key = arg1 value = value1
key = arg2 value = value2
key = apple value = red
key = datetime value = 03.11.2025 15:31
'''
result = shell.execute("calc 1 2")
print(result.result) # 3.0
result = shell.execute("calc 1 2 --action +")
print(result.result) # 3.0
result = shell.execute("calc 1 2 --action *")
print(result.result) # 2.0
result = shell.execute("calc 1 2 --action pow")
print(result.result) # Incorrect type of action
main()
Metadata
Release files for callixir 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 |
|---|---|---|---|---|
| callixir-0.1.1.tar.gz | 6.2 kB | Without provenance | Details for callixir-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| callixir-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for callixir-0.1.1-py3-none-any.whl |
Total release size: 17.3 kB
Release files / callixir-0.1.1.tar.gz
| Download URL | callixir-0.1.1.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b21e332d60b29f54f3420e2900931e512aabc76aa07632f3af93b7158079d721
|
|
BLAKE2b-256 checksum How to use checksums |
822463fb6d8b46c24bf1993995ab325017730221ff75099b7ce22d84fcae66a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.11 Windows/10
|
Release files / callixir-0.1.1-py3-none-any.whl
| Download URL | callixir-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fe3a23e67f30339b2eb356015980c15736d3cdacdf5c9476250b6ac026565d7
|
|
BLAKE2b-256 checksum How to use checksums |
3573043f304288c6d19cc8892383db3832e2dfe0013158e50931cbecedcf5fcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.11 Windows/10
|
Security for callixir 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.