A comprehensive Python library of standard CLI utilities for convenient command, I/O, and file handling.
Project description
CLIbrary
A comprehensive Python library of standard CLI utilities for convenient command, I/O, and file handling.
Make sure to take a look at the documentation and at the contributing guidelines.
Installation
Installing CLIbrary
CLIbrary can be installed from PyPI by:
python3 -m pip install --upgrade CLIbrary
Verify installation
The installation of CLIbrary can be verified by:
python3 -m CLIbrary
which would return something similar to[^1]:
● 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
[^1]: Example referring to version 1.7.2
Importing CLIbrary
CLIbrary can be imported by:
import CLIbrary
Examples
These are some examples from existing projects[^2].
Command line interface
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"]
[^2]: "..." indicates missing code.
Asking for input
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) + "\""})
Loading and dumping a file
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)
Set values for global settings
An example from openTree
import CLIbrary
...
CLIbrary.data.setting_fileExtension = ".ot"
...
if userData.darkTheme:
CLIbrary.style.setting_darkMode = True
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
File details
Details for the file clibrary-1.8.1.tar.gz
.
File metadata
- Download URL: clibrary-1.8.1.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e889c65a4fd851399dea943daa56eabd8030b9536bd2603c0ba5a7d816d54986 |
|
MD5 | ea08c13cd60ebe4e080ae61d791e24f4 |
|
BLAKE2b-256 | a373c499bcbe98cc3fd4c0d6f5fe755b8cbf55ff9196e0aa4395e12a4ddf2cbf |
File details
Details for the file clibrary-1.8.1-py3-none-any.whl
.
File metadata
- Download URL: clibrary-1.8.1-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85c665e217dd75396f9858c2e26bc482fbe5244d037abe895079413c54db45da |
|
MD5 | 04e3bd37779338352e2c57b4cdd24085 |
|
BLAKE2b-256 | 8b7e486ad0bde826d4ccafa2bf87131f42b636a260e8adef2c0c3f54be225e97 |