Skip to main content

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.

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.

Make sure to take a look at the documentation, at the contributing guidelines and at the examples.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clibrary-1.9.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

clibrary-1.9.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file clibrary-1.9.0.tar.gz.

File metadata

  • Download URL: clibrary-1.9.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for clibrary-1.9.0.tar.gz
Algorithm Hash digest
SHA256 d226d1259cb5a582de61529652752f10f92ef0bad299d4502257c96a353f98fb
MD5 7f83291622d4b88a2d7e9c93eff72b0a
BLAKE2b-256 29b0a09b986f02791d31056d61f304326931e60809922b26e58c5090abc99b8c

See more details on using hashes here.

File details

Details for the file clibrary-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: clibrary-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for clibrary-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61b94c0191d4080b6a12cfe73259a6a85a2c599b9a10dddaea89719650fdc5bf
MD5 211389cb74a80d0a8db896edb3e22bb6
BLAKE2b-256 74cedb545d074939e8d3f4f63069d0bed522b57414626082e01803be98ca077a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page