SVK::Command(3)

πŸ“¦
version 2.2.3 Β· 2 versions
, in fedora 43

πŸ’– 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 %alias map. 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 %opt getopt 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 in recursive.
  • parse_arg (@args) β€” this one gets called with whatever arguments are left over after named options get parsed with options above. it should use the arg_* methods to return a list of parsed arguments for the command's lock and run methods to process. defaults to returning a single undef. πŸ™ˆ
  • lock (@parse_args) β€” calls the lock_* methods to lock the SVK::XD object. the arguments will be whatever came back from parse_arg.
  • run (@parsed_args) β€” actually does the thing. processes the command, fr fr. the arguments will be whatever came back from parse_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:

  • cinfo
  • copath
  • depotpath
  • path
  • repos
  • repospath
  • report
  • targets

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 via arg_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 -c or -r into 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_detail is true, the DESCRIPTION section 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 $cmd subclass 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) β€” like command above, 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 $target and invokes $code with 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