Wilson Snyder > P4-C4-2.041 > P4::Getopt



Annotate this POD

View/Report Bugs
Module Version: 2.041   Source  


P4::Getopt - Get P4 command line options


  use P4::Getopt;

  my $opt = new P4::Getopt;
  $opt->parameter (qw( -u username ));

  @ARGV = $opt->parameter (@ARGV);

The P4::Getopt package provides standardized handling of global options for the front of P4 commands.

$opt = P4::Getopt->new ( opts )

Create a new Getopt.

$self->get_parameter ( )

Returns a list of parameters that when passed through $self->parameter() should result in the same state. Often this is used to form command lines for wrappers that want to call p4 underneath themselves.

$self->parameter ( \@params )

Parses any recognized parameters in the referenced array, removing the standard parameters and returning a array with all unparsed parameters.

The below list shows the parameters that are supported, and the functions that are called:

    -c <client>      client
    -d <pwd>         pwd
    -H <host>        host
    -p <port>        port
    -P <password>    password
    -s               script (set true)
    -u <user>        user
    -C <charset>     charset
    -n               noop (set true)    CVS compatible option

    -x <file>        Read given file and parse args automatically


There is a accessor for each parameter listed above. In addition:


Return sorted list of all commands.


Return textual description of the specified command.


The filename and line number last parsed.

$self->hashCmd(<cmd>, <opts>)

Return a hash with one key for each option. The value of the key is 1 if a no-argument option was set, else it is an array with each value the option was set to.

$self->parseCmd(<cmd>, <opts>)

Return a array with one element for each option. The element is either 'switch', the name of the switch the option is specifying, or the name of the parameter.


Set the client, port, and password based on the options.

$self->stripOneArg(-<arg>, <opts>...)

Return the option list, with the specified matching argument removed.


The latest version is available from CPAN and from http://www.veripool.com/.

Copyright 2002-2005 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License or the Perl Artistic License.


Wilson Snyder <wsnyder@wsnyder.org>



syntax highlighting: