man SVK::Command () - Base class and dispatcher for SVK commands
NAME
SVK::Command - Base class and dispatcher for SVK commands
SYNOPSIS
use SVK::Command; my $xd = SVK::XD->new ( ... ); my $cmd = 'checkout'; my @args = qw( file1 file2 ); open my $output_fh, '>', 'svk.log' or die $!; SVK::Command->invoke ($xd, $cmd, $output_fh, @args);
DESCRIPTION
This module resolves alias for commands and dispatches them, usually with the CWinvoke method. If the command invocation is incorrect, usage information is displayed instead.
METHODS
Class Methods
new ($xd)
Base constructor for all commands.
get_cmd ($cmd, CI$xd)
Load the command subclass specified in CW$cmd, and return a new instance of it, populated with CW$xd. Command aliases are handled here.
To construct a command object from another command object, use the CWcommand instance method instead.
invoke ($xd, CI$cmd, CI$output_fh, CI@args)
Takes a SVK::XD object, the command name, the output scalar reference, and the arguments for the command. The command name is translated with the CW%alias map.
On Win32, after CW@args is parsed for named options, the remaining positional arguments are expanded for shell globbing with CWbsd_glob.
getopt ($argv, CI%opt)
Takes a arrayref of argv for run getopt for the command, with additional CW%opt getopt options.
Instance Methods
CWSVK::Command->invoke loads the corresponding class CWSVK::Command::CI$nameCW, so that's the class you want to implement the following methods in:
options ()
Returns a hash where the keys are Getopt::Long specs and the values are a string that will be the keys storing the parsed option in CW$self.
Subclasses should override this to add their own options. Defaults to an empty list.
opt_recursive
Defines if the command needs the recursive flag and its default. The value will be stored in CWrecursive.
parse_arg (@args)
This method is called with the remaining arguments after parsing named options with CWoptions above. It should use the CWarg_* methods to return a list of parsed arguments for the command's CWlock and CWrun method to process. Defaults to return a single CWundef.
lock (@parse_args)
Calls the CWlock_* methods to lock the SVK::XD object. The arguments will be what is returned from CWparse_arg.
run (@parsed_args)
Actually process the command. The arguments will be what is returned from CWparse_arg.
Returned undef on success. Return a string message to notify the caller errors.
Utility Methods
Except for CWarg_depotname, all CWarg_* methods below returns a SVK::Target object, which consists of a hash with the following keys:
- cinfo
- copath
- depotpath
- path
- repos
- repospath
- report
- targets
The hashes are handy to pass to many other functions.
arg_condensed (@args)
Argument is a number of checkout paths.
arg_uri_maybe ($arg, CI$no_new_mirror)
Argument might be a URI or a depotpath. If it is a URI, try to find it at or under one of currently mirrored paths. If not found, prompts the user to mirror and sync it.
arg_co_maybe ($arg, CI$no_new_mirror)
Argument might be a checkout path or a depotpath. If argument is URI then handles it via CWarg_uri_maybe.
arg_copath ($arg)
Argument is a checkout path.
arg_depotpath ($arg)
Argument is a depotpath, including the slashes and depot name.
arg_depotroot ($arg)
Argument is a depot root, or a checkout path that needs to be resolved into a depot root.
arg_depotname ($arg)
Argument is a name of depot. such as '' or 'test' that is being used normally between two slashes.
arg_path ($arg)
Argument is a plain path in the filesystem.
parse_revlist ()
Parse -c or -r to a list of [from, to] pairs.
lock_target ($target)
XXX Undocumented
lock_coroot ($target)
XXX Undocumented
brief_usage ($file)
Display an one-line brief usage of the command object. Optionally, a file could be given to extract the usage from the POD.
filename
Return the filename for the command module.
usage ($want_detail)
Display usage. If CW$want_detail is true, the CWDESCRIPTION section is displayed as well.
Error Handling
handle_error ($error)
XXX Undocumented
add_handler ($error, CI$handler)
XXX Undocumented
msg_handler ($error, CI$message)
XXX Undocumented
msg_handler ($error)
XXX Undocumented
command ($cmd, \%args)
Construct a command object of the CW$cmd subclass and return it.
The new object will share the CWxd from the calling command object; contents in CW%args is also assigned into the new object.
rebless ($cmd, \%args)
Like CWcommand above, but modifies the calling object instead of creating a new one. Useful for a command object to recast itself into another command class.
SEE ALSO
SVK, SVK::XD, CWSVK::Command::*
AUTHORS
Chia-liang Kao <clkao@clkao.org>
COPYRIGHT
Copyright 2003-2005 by Chia-liang Kao <clkao@clkao.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>