SVK::Command - Base class and dispatcher for SVK commands
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);
This module resolves alias for commands and dispatches them, usually with the invoke method. If the command invocation is incorrect, usage information is displayed instead.
invoke
Base constructor for all commands.
Load the command subclass specified in $cmd, and return a new instance of it, populated with $xd. Command aliases are handled here.
$cmd
$xd
To construct a command object from another command object, use the command instance method instead.
command
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 %alias map.
%alias
On Win32, after @args is parsed for named options, the remaining positional arguments are expanded for shell globbing with bsd_glob.
@args
bsd_glob
Takes a arrayref of argv for run getopt for the command, with additional %opt getopt options.
SVK::Command->invoke loads the corresponding class SVK::Command::$name, so that's the class you want to implement the following methods in:
SVK::Command->invoke
SVK::Command::$name
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 $self.
$self
Subclasses should override this to add their own options. Defaults to an empty list.
Defines if the command needs the recursive flag and its default. The value will be stored in recursive.
recursive
This method is called with the remaining arguments after parsing named options with options above. It should use the arg_* methods to return a list of parsed arguments for the command's lock and run method to process. Defaults to return a single undef.
options
arg_*
lock
run
undef
Calls the lock_* methods to lock the SVK::XD object. The arguments will be what is returned from parse_arg.
lock_*
parse_arg
Actually process the command. The arguments will be what is returned from parse_arg.
Returned undef on success. Return a string message to notify the caller errors.
Except for arg_depotname, all arg_* methods below returns a SVK::Target object, which consists of a hash with the following keys:
arg_depotname
The hashes are handy to pass to many other functions.
Argument is a number of checkout paths.
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.
Argument might be a checkout path or a depotpath. If argument is URI then handles it via arg_uri_maybe.
arg_uri_maybe
Argument is a checkout path.
Argument is a depotpath, including the slashes and depot name.
Argument is a depot root, or a checkout path that needs to be resolved into a depot root.
Argument is a name of depot. such as '' or 'test' that is being used normally between two slashes.
Argument is a plain path in the filesystem.
Parse -c or -r to a list of [from, to] pairs.
XXX Undocumented
Display an one-line brief usage of the command object. Optionally, a file could be given to extract the usage from the POD.
Display usage. If $want_detail is true, the DESCRIPTION section is displayed as well.
$want_detail
DESCRIPTION
Construct a command object of the $cmd subclass and return it.
The new object will share the xd from the calling command object; contents in %args is also assigned into the new object.
xd
%args
Like command above, but modifies the calling object instead of creating a new one. Useful for a command object to recast itself into another command class.
SVK, SVK::XD, SVK::Command::*
SVK::Command::*
Chia-liang Kao <clkao@clkao.org>
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
To install SVK, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SVK
CPAN shell
perl -MCPAN -e shell install SVK
For more information on module installation, please visit the detailed CPAN module installation guide.