Skip to main content

The Dazed Gerbil's Command Line Tools

Project description

The Dazed Gerbil's Command Line Tools

This is intended to become a simple set of tools I use on a regular basis when developing a cli based app.

You almost certainly don't want to use this. There are probably hundreds of alternatives on PyPi already - each one notably better than my own.

Regardless, if you're determined to cause yourself pain, what does this library do? Not much so far, even less if you don't install it. Handily it's on pypi so just 'pip install dg_clt', 'uv add dg_clt', or whatever your package manager of choice requires.

dg_clt.screen

This little function exists out of sheer laziness on my part. All it does is clear the terminal window while remaining platform independent.

import dg_clt as tdg

tdg.screen.clear()

The entire code to provide that function is as follows:

import os

clear = lambda: os.system('cls' if os.name == 'nt' else 'clear')

I can just never recall the line off-hand when I need it.

dg_clt.menus

This is a simple class that will clear the screen, display a menu from data you pass in, and return the user's choice once they select a correct menu item.

The Menu class accepts a title as a string, the list of menu items as a dictionary (using a blank key to display a blank line), and a prompt to ask the user to select a menu item (optional, with a default of '> '). The user's choice will be returned as a string.

import dg_clt as tdg

main_menu = tdg.menus.Menu(title='Main Menu',
                           menu_items={'1': 'First item',
                                       '2': 'Second item',
                                       '3': 'Final item',
                                       '':'',
                                       'q': 'Quit the application'},
                           selection="What's it to be? ")

user_choice = main_menu.get_input()

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

dg_clt-0.2.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dg_clt-0.2.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file dg_clt-0.2.0.tar.gz.

File metadata

  • Download URL: dg_clt-0.2.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for dg_clt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 29e20af807e72cde884257d753a6b8cfd19976c252eefebe03fb0dcdf97dd9ea
MD5 be841d84ed0d0eea7812ccae24a44b84
BLAKE2b-256 e74a14e125a212f8255d9102bcb69f1370730f79e8e4fdb1bed3e4f1d4b858f2

See more details on using hashes here.

File details

Details for the file dg_clt-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dg_clt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for dg_clt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3039c20505f901c793eea2fa22b482d2114fc2043d87d73da6961a0ea1e1fd8c
MD5 6e934c439aca21991152d7119d6b9e6a
BLAKE2b-256 50ce50751c18629353a85a2bcfadd628631c44a13bdf1436dedc3f06bfb3dfc0

See more details on using hashes here.

Supported by

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