SVK::Command(3)
π NAME π
SVK::Command β bestie, this is the base class AND the dispatcher for all your 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 πΈ
okay so this module is the one that figures out aliases for commands and then yeets them off to the right place β usually via the invoke method. and if you mess up the command invocation? it doesn't yell at you, it just shows you the usage info instead. very demure, very mindful π
π METHODS π
Class Methods π
invoke ($xd, $cmd, $output_fh, @args)β takes an SVK::XD object, the command name, the output scalar reference, and the args for the command. the command name gets translated through the%aliasmap. slay
on Win32, after @args gets parsed for named options, whatever positional arguments are left get expanded for shell globbing with bsd_glob. windows besties, that one's for you πͺβ¨
getopt ($argv, %opt)β hand it an arrayref of argv so it can run getopt for the command, plus whatever extra%optgetopt options you wanna throw in there.
Instance Methods π¦
the way that SVK::Command->invoke loads up the matching class SVK::Command::$name β that's literally the class where you're supposed to implement all of these:
options ()β returns a hash where the keys are Getopt::Long specs and the values are a string that becomes the key storing the parsed option in$self.
subclasses should override this to add their own options. defaults to an empty list. no cap.
opt_recursiveβ defines whether the command needs the recursive flag, and what its default is. the value gets stored inrecursive.parse_arg (@args)β this one gets called with whatever arguments are left over after named options get parsed withoptionsabove. it should use thearg_*methods to return a list of parsed arguments for the command'slockandrunmethods to process. defaults to returning a singleundef. πlock (@parse_args)β calls thelock_*methods to lock the SVK::XD object. the arguments will be whatever came back fromparse_arg.run (@parsed_args)β actually does the thing. processes the command, fr fr. the arguments will be whatever came back fromparse_arg.
returns undef on success. returns a string message to notify the caller about errors. so like, no return = we ate, a string = something went sideways π
Utility Methods π§
except for arg_depotname, all the arg_* methods below return an SVK::Path object, which is basically a hash with these keys:
cinfocopathdepotpathpathreposrepospathreporttargets
these hashes are super handy to pass around to lots of other functions. iconic little grab bag π
arg_condensed (@args)β the argument is a number of checkout paths.arg_uri_maybe ($arg, $no_new_mirror)β the argument might be a URI or a depotpath. if it's a URI, it tries to find it at or under one of the currently mirrored paths. if it's not found, it prompts the user to mirror and sync it. β¨arg_co_maybe ($arg, $no_new_mirror)β the argument might be a checkout path or a depotpath. if the argument is a URI, it handles it viaarg_uri_maybe.arg_copath ($arg)β the argument is a checkout path.arg_depotpath ($arg)β the argument is a depotpath, slashes and depot name included. don't forget the slashes bestie.arg_depotroot ($arg)β the argument is a depot root, or a checkout path that needs to be resolved into a depot root.arg_depotname ($arg)β the argument is a name of a depot, like''or'test', the kind that's normally used between two slashes.arg_path ($arg)β the argument is a plain path in the filesystem. just a lil guy πapply_revision($target)β applies the given revision from the command line to$target.parse_revlist ()β parses-cor-rinto a list of[from, to]pairs.lock_target ($target)β XXX Undocumented. πlock_coroot ($target)β XXX Undocumented. πbrief_usage ($file)β displays a one-line brief usage of the command object. optionally you can pass a file to extract the usage from the POD.filenameβ returns the filename for the command module.usage ($want_detail)β displays usage. if$want_detailis true, theDESCRIPTIONsection gets displayed too. the deluxe version π
Error Handling π¨
handle_error ($error)β XXX Undocumented. πadd_handler ($error, $handler)β XXX Undocumented. πmsg_handler ($error, $message)β XXX Undocumented. πmsg_handler ($error)β XXX Undocumented. πcommand ($cmd, \%args)β constructs a command object of the$cmdsubclass and returns it.
the new object will share the xd from the calling command object; contents in %args are also assigned into the new object.
rebless ($cmd, \%args)β likecommandabove, but it modifies the calling object instead of creating a brand new one. super useful for a command object to recast itself into another command class. main character energy, honestly πrun_command_recursively($target, $code)β traverses$targetand invokes$codewith each node. every single one. no skips. π₯
π SEE ALSO π
SVK, SVK::XD, SVK::Command::*
and that's the whole page bestie!! you read all of it, i'm so proud of you π₯Ήπ
okay so this was written against perl v5.42.0 and dated 2025-07-25 β go forth and dispatch some commands, you absolute legend π β¨πΈ
π¦ where this page comes from
- fedora 43: perl-SVK 2.2.3-45.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms