Cliff Classes

App

class cliff.app.App(description, version, command_manager, stdin=None, stdout=None, stderr=None)

Application base class.

build_option_parser(description, version)

Return an argparse option parser for this application.

Subclasses may override this method to extend the parser with more global options.

clean_up(cmd, result, err)

Hook run after a command is done to shutdown the app.

configure_logging()

Create logging handlers for any log output.

prepare_to_run_command(cmd)

Perform any preliminary work needed to run a command.

run(argv)

Equivalent to the main program for the application.

CommandManager

class cliff.commandmanager.CommandManager(namespace)

Discovers commands and handles lookup based on argv data.

find_command(argv)

Given an argument list, find a command and return the processor and any remaining arguments.

Command

class cliff.command.Command(app, app_args)

Base class for command plugins.

get_description()

Return the command description.

get_parser(prog_name)

Return an argparse.ArgumentParser.

run(parsed_args)

Do something useful.

ShowOne

class cliff.show.ShowOne(app, app_args)

Command base class for displaying data about a single object.

get_data(parsed_args)

Return a two-part tuple with a tuple of column names and a tuple of values.

Lister

class cliff.lister.Lister(app, app_args)

Command base class for providing a list of data as output.

get_data(parsed_args)

Return a tuple containing the column names and an iterable containing the data to be listed.

Formatter

class cliff.formatters.base.Formatter
add_argument_group(parser)

Add any options to the argument parser.

Should use our own argument group.

ListFormatter

class cliff.formatters.base.ListFormatter

Base class for formatters that know how to deal with multiple objects.

emit_list(column_names, data, stdout, parsed_args)

Format and print the list from the iterable data source.

Parameters:
  • column_names – names of the columns
  • data – iterable data source, one tuple per object with values in order of column names
  • stdout – output stream where data should be written
  • parsed_args – argparse namespace from our local options

SingleFormatter

class cliff.formatters.base.SingleFormatter

Base class for formatters that work with single objects.

emit_one(column_names, data, stdout, parsed_args)

Format and print the values associated with the single object.

Parameters:
  • column_names – names of the columns
  • data – iterable data source with values in order of column names
  • stdout – output stream where data should be written
  • parsed_args – argparse namespace from our local options

Table Of Contents

Previous topic

Show Commands

Next topic

Installation

This Page