Skip to content

anki-code/xonsh-awesome-cli-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example of awesome CLI app template for xonsh. Just fork it and add your commands.

If you like the idea of bar theme click ⭐ on the repo and tweet.

Features

  • Based on power and sugar from click.
  • Pip-installable as well as clone-and-run.
  • Ability to grow your library.
  • Ability to set up context and environment.
  • Ability to set up context options and command arguments.
  • Ability to use environment variables as replacement of options and arguments.
  • Logging included.

Install

pip install git+https://github.com/anki-code/xonsh-awesome-cli-app
mycli

or

git clone https://github.com/anki-code/xonsh-awesome-cli-app
cd xonsh-awesome-cli-app
./mycli

Usage

You can use this app as a template to your own apps.

mycli
# Usage: mycli [OPTIONS] COMMAND [ARGS]...
# 
#   CLI management.
# 
# Options:
#   --name TEXT  Context option: name.
#   --debug      Context option: debug mode.
#   --help       Show this message and exit.
# 
# Commands:
#  say      Say.
#  context  Show app context.

mycli hello --help
# Usage: mycli hello [OPTIONS]
# 
#   Say hello.
# 
# Options:
#   --wait  Command argument: wait before print.
#   --help  Show this message and exit.

mycli say hello
# Username say: hello

mycli say hello --wait
# Wait...
# Username say: hello

mycli --name Mike say hello --wait
# Wait...
# Mike say: hello

$MYCLI_NAME = 'Alex'
mycli say hello
# Alex say: hello

mycli context
# Environment:
# {'MYCLI_NAME': 'Alex'}
# Context:
# {'debug': False, 'log': <RootLogger root (INFO)>, 'name': 'Alex'}

mycli --debug say hello
# TRACE SUBPROC: (['echo', 'Username', 'say:', 'hello'],), captured=hiddenobject
# Username say: hello
# 2024-03-01 18:21:24,723 - root - INFO - Additional log message.
# TRACE SUBPROC: (['echo', 'Here', 'is', 'debug', 'message', 'too', ''],), captured=hiddenobject
# Here is debug message too

See more CLI libs

See also