vcs 0.4.0 documentation

This Page

vcs.cli

Command line interface for VCS

This module provides foundations for creating, executing and registering terminal commands for vcs. Moreover, ExecutionManager makes it possible for user to create own code (at .vcsrc file).

vcs.cli.ExecutionManager

class vcs.cli.ExecutionManager(argv=None, stdout=None, stderr=None)

Class for command execution management.

execute()

Executes whole process of parsing and running command.

get_argv_for_command()

Returns stripped arguments that would be passed into the command.

get_command_class(cmd)

Returns command class from the registry for a given cmd.

Parameters:cmd – command to run (key at the registry)
get_commands()

Returns commands stored in the registry.

get_vcsrc()

Returns in-memory created module pointing at user’s configuration and extra code/commands. By default tries to create module from VCSRC_PATH.

run_command(cmd, argv)

Runs command.

Parameters:
  • cmd – command to run (key at the registry)
  • argv – arguments passed to the command
show_help()

Prints help text about available commands.

vcs.cli.BaseCommand

class vcs.cli.BaseCommand(stdout=None, stderr=None)

Base command class.

execute(*args, **options)

Executes whole process of parsing arguments, running command and trying to catch errors.

get_option_list()

Returns options specified at self.option_list.

get_parser(prog_name, subcommand)

Returns parser for given prog_name and subcommand.

Parameters:
  • prog_name – vcs main script name
  • subcommand – command name
get_version()

Returns version of vcs.

handle(*args, **options)

This method must be implemented at subclass.

print_help(prog_name, subcommand)

Prints parser’s help.

Parameters:
  • prog_name – vcs main script name
  • subcommand – command name
run_from_argv(argv)

Runs command for given arguments.

Parameters:argv – arguments
usage(subcommand)

Returns how to use command text.

vcs.cli.RepositoryCommand

class vcs.cli.RepositoryCommand(stdout=None, stderr=None, repo=None)

Base repository command.

Accepts extra argument:

Parameters:repo – repository instance. If not given, repository would be calculated based on current directory.
handle(*args, **options)

Runs pre_process, handle_repo and post_process methods, in that order.

handle_repo(repo, *args, **options)

Handles given repository. This method must be implemented at subclass.

post_process(repo, **options)

This method would be run at the end of handle method. Does nothing by default.

pre_process(repo, **options)

This method would be run at the beginning of handle method. Does nothing by default.

vcs.cli.ChangesetCommand

class vcs.cli.ChangesetCommand(stdout=None, stderr=None, repo=None)

Subclass of RepositoryCommand.

Extra options

  • show_progress_bar: specifies if bar indicating progress of processed changesets should be shown.

Accepts extra argument:

Parameters:repo – repository instance. If not given, repository would be calculated based on current directory.
get_changesets(repo, **options)

Returns generator of changesets from given repo for given options.

Parameters:repo – repository instance. Same as self.repo.

Available options

  • start_date: only changesets not older than this parameter would be generated
  • end_date: only changesets not younger than this parameter would be generated
  • start: changeset’s ID from which changesets would be generated
  • end: changeset’s ID to which changesets would be generated
  • branch: branch for which changesets would be generated. If all flag is specified, this option would be ignored. By default, branch would by tried to retrieved from working directory.
  • all: return changesets from all branches
  • reversed: by default changesets are returned in date order. If this flag is set to True, reverse order would be applied.
  • limit: if specified, show no more changesets than this value. Default is None.
get_progressbar(total, **options)

Returns progress bar instance for a given total number of clicks it should do.

handle_changeset(changeset, **options)

Handles single changeset. Must be implemented at subclass.

vcs.cli.SingleChangesetCommand

class vcs.cli.SingleChangesetCommand(stdout=None, stderr=None, repo=None)

Single changeset command. Convenient if command has to operate on single changeset rather than whole generator. For usage i.e. with command that handles node(s) from single changeset.

Extra options

  • min_args: minimal number of arguements to parse. Default is 1.

Accepts extra argument:

Parameters:repo – repository instance. If not given, repository would be calculated based on current directory.
get_changeset(**options)

Returns changeset for given options.

handle_arg(changeset, arg, **options)

Handles single argument for chosen changeset. Must be implemented at subclass.

Parameters:
  • changeset – chosen (by --commit option) changeset
  • arg – single argument from arguments list