Skip to main content

PyPI GitHub last commit GitHub Release Date

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.
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.

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 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

Importing CLIbrary

CLIbrary can be imported by:

import CLIbrary

Examples

These are some examples from existing projects2.

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"]

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
  1. Example referring to version 1.7.2 ↩

  2. "..." indicates missing code. ↩

Metadata

Release files for CLIbrary 1.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CLIbrary 1.10.0
File Size Uploaded
clibrary-1.10.0.tar.gz 27.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for CLIbrary 1.10.0
File Interpreter ABI Platform
clibrary-1.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.1 kB

Release files / clibrary-1.10.0.tar.gz

Download URL clibrary-1.10.0.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c393517b913967f4e370e39f697ffe54d4f5121a1153008a50ec3d893d093fe3
BLAKE2b-256 checksum
How to use checksums
010c75db84a100cc373528642291f01aa0469a38f685aa78cd5600aaf54b674f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / clibrary-1.10.0-py3-none-any.whl

Download URL clibrary-1.10.0-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d864543ff6df995858322afd0a240277595ee18453441e00724953fd1e906e3
BLAKE2b-256 checksum
How to use checksums
6905835907e3d108ff0e7dbc25409308ec0788e48c7507a2739f8e14d027b229
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

1.10.0 This release

2 release files

1.9.0

2 release files

1.8.1

2 release files

1.7.2

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.5.0

2 release files

1.4.3

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.1.2

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page