gallium.cli.core

This module is designed to speed up the development of command line apps without needing to specify arguments. The arguments will be defined based on the signature of the decorated methods used to handle the command line input.

Quick start

You can use the default console from gallium.cli.core or create your own.

For example, create app.py with the following source code.

from gallium.cli.core import console

@console.command(["set", "config"])
def set_config(name: str):
    ''' Example to humanized command '''
    print(name)

@console.command("auth")
def authenticate(name: str):
    ''' Example to humanized command '''
    print(name)

@console.simple_command
def add(a: int, b: int):
    print(a + b)

console.run_with()

Then, you should be able to call set_config, authenticate, and add by invoking:

  • python3 app.py set config --name panda

  • python3 app.py auth --name foo

  • python3 app.py add --a 1 --b 2

respectively.

class gallium.cli.core.Command(id: List[str], callable: Callable, description: Optional[str] = None)

Command Metadata

class gallium.cli.core.Console

Console (Argument Parser Wrapper)

command(id: Union[None, str, List[str]] = None, description: Optional[str] = None)

A decorator to define a command

Warning

This only works on static methods or functions.

gallium.cli.core.console: gallium.cli.core.Console = <gallium.cli.core.Console object>

Default/Standalone Console