API

clik_shell.exclude_from_shell(command_or_fn)[source]

Exclude command from the shell interface.

This decorator can be applied before or after the command decorator:

@exclude_from_shell
@myapp
def mycommand():

# is the same as

@myapp
@exclude_from_shell
def mycommand():
Parameters:command_or_fn (clik.command.Command or function) – Command instance or function
Returns:Whatever was passed in
class clik_shell.BaseShell(command)[source]

Bases: cmd.Cmd

Minimal implementation to integrate clik and cmd.

__init__(command)[source]

Instantiate the command loop.

Parameters:command (clik.command.Command) – “Root” command object (usually the application object created by clik.app.app())
default(line)[source]

Override that hackily supports commands with hyphens.

See the quickstart in the documentation for further explanation.

Parameters:line (str) – Line whose command is unrecognized
Return type:None
error(exit_code)[source]

Handle non-zero subcommand exit code.

By default, this prints a generic error message letting the user know the exit code.

Parameters:exit_code (int) – Exit code from the subcommand
Return type:None
prompt = None

Prompt for the command loop. If None, the prompt is set to "name> ", where name is the name of the root command object.

Type:str or None
class clik_shell.DefaultShell(command)[source]

Bases: clik_shell.BaseShell

Command loop subclass that implements commonly desire facilities.

cmdloop()[source]

Override that supports graceful handling of keyboard interrupts.

do_EOF(_)[source]

Exit the shell.

do_exit(_)[source]

Exit the shell.

do_quit(_)[source]

Exit the shell.

emptyline()[source]

Override that turns an empty line into a no-op.

By default, the command loop runs the previous command when an empty line is received. This is bad default behavior because it’s not what users expect.

If “run the last command” is the desired behavior, you should extend BaseClass rather than this class.