A comprehensive Python library of standard CLI utilities for convenient command, I/O, and file handling.
CLIbrary is a comprehensive Python library that makes command line usage, input/output, and file handling easier and more efficient. It provides a wide range of tools for interacting with a shell, including essential utilities for command line parsing and I/O, file manipulations, tab completion, and command hinting. With these tools, CLIbrary makes it easy to integrate powerful command-line functionality into any Python project.
Additionally, it now also provides a history feature for tracking and re-executing previous commands.
Make sure to take a look at the documentation, at the contributing guidelines and at the examples.
CLIbrary can be installed from PyPI by:
python3 -m pip install --upgrade CLIbrary
The installation of CLIbrary can be verified by:
python3 -m CLIbrary
which would return something similar to1:
● CLIbrary v1.7.2
A comprehensive Python library of standard CLI utilities for convenient command, I/O, and file handling.
Developed by Andrea Di Antonio, more on https://github.com/diantonioandrea/CLIbrary
Documentation on https://github.com/diantonioandrea/CLIbrary/blob/main/docs.md
Bug tracker on https://github.com/diantonioandrea/CLIbrary/issues
CLIbrary can be imported by:
import CLIbrary
These are some examples from existing projects2.
An example from openTree
import CLIbrary
...
cmdHandler = {"request": "[" + user.name + "@" + name + "]"}
cmdHandler["style"] = Fore.MAGENTA
cmdHandler["helpPath"] = helpPath
...
cmdHandler["allowedCommands"] = ["set", "password", "delete", "new"]
...
command = CLIbrary.cmdIn(cmdHandler)
cmd = command["command"]
sdOpts = command["sdOpts"]
ddOpts = command["ddOpts"]
Some examples from openBriefcase
import CLIbrary
...
class account:
def __init__(self, otherNames: list):
self.name = CLIbrary.strIn({"request": "Account name", "space": False, "blockedAnswers": otherNames})
self.start = CLIbrary.numIn({"request": "Starting balance"})
...
class movement:
def __init__(self, otherCodes: list):
...
self.reason = CLIbrary.strIn({"request": "Movement reason", "allowedChars": ["-", "'", ".", ",", ":"]})
self.amount = CLIbrary.numIn({"request": "Movement amount"})
self.date = CLIbrary.dateIn({"request": "Movement date"})
...
self.confirmation = CLIbrary.boolIn({"request": "Verify \"" + str(self) + "\""})
An example from openTree
import CLIbrary
...
user = openTree.user()
fileHandler = {"path": dataPath + user.name, "ignoreMissing": True}
userData = CLIbrary.aLoad(fileHandler)
...
fileHandler["data"] = user
CLIbrary.aDump(fileHandler)
An example from openTree
import CLIbrary
...
CLIbrary.data.setting_fileExtension = ".ot"
...
if userData.darkTheme:
CLIbrary.style.setting_darkMode = True