SVN-S4
view release on metacpan or search on metacpan
lib/SVN/S4/Getopt.pm view on Meta::CPAN
# See copyright, etc in below POD section.
######################################################################
package SVN::S4::Getopt;
use strict;
use vars qw($AUTOLOAD $Debug);
use Carp;
use IO::File;
use Cwd;
use Data::Dumper;
######################################################################
#### Configuration Section
our $VERSION = '1.066';
our %_Aliases =
(
'ann' => 'blame',
'annotate' => 'blame',
'ci' => 'commit',
'cl' => 'changelist',
'co' => 'checkout',
'cp' => 'copy',
'del' => 'delete',
'di' => 'diff',
'h' => 'help',
'ls' => 'list',
'mv' => 'move',
'pd' => 'propdel',
'pdel' => 'propdel',
'pe' => 'propedit',
'pedit' => 'propedit',
'pg' => 'propget',
'pget' => 'propget',
'pl' => 'proplist',
'plist' => 'proplist',
'praise' => 'blame',
'ps' => 'propset',
'pset' => 'propset',
'remove' => 'delete',
'ren' => 'move',
'rename' => 'move',
'rm' => 'delete',
'snap' => 'snapshot',
'st' => 'status',
'stat' => 'status',
'sw' => 'switch',
'up' => 'update',
# S4 additions
'qci' => 'quick-commit',
);
# List of commands and arguments.
# Forms:
# [-switch]
# [-switch argument]
# nonoptional # One parameter
# nonoptional... # Many parameters
# [optional] # One parameter
# [optional...] # Many parameters
# The arguments "PATH*" are specially detected by s4 for filename parsing.
our %_Args =
(
'add' => {
s4_changed => 1,
args => (''
.' [--no-fixprop]' # S4 addition
.' [--fixprop]' # S4 addition
#
.' [--auto-props]'
.' [--depth ARG]' # 1.6
.' [--force]'
.' [--no-auto-props]'
.' [--no-ignore]' # 1.8
.' [--parents]' # 1.6
.' [--targets FILENAME]'
.' [-N|--non-recursive]'
.' [-q|--quiet]'
#
.' [--username USER]'
.' [--password PASS]'
.' [--no-auth-cache]'
.' [--non-interactive]'
.' [--trust-server-cert]' # 1.6
.' [--config-dir DIR]'
.' [--config-option ARG]' # 1.6
.' PATH...')},
'blame' => {
args => (''
.' [--force]' # 1.4
.' [--incremental]' # 1.6
.' [--xml]' # 1.6
.' [-g|--use-merge-history]' # 1.6
.' [-r|--revision REV]'
.' [-v|--verbose]'
.' [-x|--extensions ARGS]' # 1.4
#
.' [--username USER]'
lib/SVN/S4/Getopt.pm view on Meta::CPAN
.' [--editor-cmd EDITOR]'
.' [--encoding ENC]'
.' [--force]'
.' [--force-log]'
.' [--revprop]'
.' [--with-revprop ARG]'
.' [-F|--file PATH]'
.' [-m|--message ARG]'
.' [-r|--revision REV]'
#
.' [--username USER]'
.' [--password PASS]'
.' [--no-auth-cache]'
.' [--non-interactive]'
.' [--trust-server-cert]' # 1.6
.' [--config-dir DIR]'
.' [--config-option ARG]' # 1.6
.' PROPNAME [PATHORURL...]')},
'propget' => {
args => (''#'propget PROPNAME [PATH[@REV]...]'
#'propget PROPNAME --revprop -r REV [URL]'
.' [--changelist ARG]'
.' [--depth ARG]' # 1.6
.' [--revprop]'
.' [--show-inherited-props]' # 1.8
.' [--strict]'
.' [--xml]'
.' [-R|--recursive]'
.' [-r|--revision REV]'
.' [-v|--verbose]'
#
.' [--username USER]'
.' [--password PASS]'
.' [--no-auth-cache]'
.' [--non-interactive]'
.' [--trust-server-cert]' # 1.6
.' [--config-dir DIR]'
.' [--config-option ARG]' # 1.6
.' PROPNAME [PATHORURL@PATHORURLREV...]')},
'proplist' => {
args => (''#'proplist [PATH[@REV]...]'
#'proplist -revprop -r REV [URL]'
.' [--changelist ARG]'
.' [--depth ARG]' # 1.6
.' [--revprop]'
.' [--show-inherited-props]' # 1.8
.' [--xml]'
.' [-R|--recursive]'
.' [-q|--quiet]'
.' [-r|--revision REV]'
.' [-v|--verbose]'
#
.' [--username USER]'
.' [--password PASS]'
.' [--no-auth-cache]'
.' [--non-interactive]'
.' [--trust-server-cert]' # 1.6
.' [--config-dir DIR]'
.' [--config-option ARG]' # 1.6
.' PROPNAME [PATHORURL@PATHORURLREV...]')},
'propset' => {
args => (''#'propset PROPNAME [PROPVAL | -F VALFILE] PATH...'
#'propset PROPNAME --revprop -r REV [PROPVAL | -F VALFILE] [URL]'
.' [--changelist ARG]'
.' [--depth ARG]' # 1.6
.' [--encoding ENC]'
.' [--force]'
.' [--revprop]'
.' [--targets FILENAME]'
.' [-F|--file FILE]'
.' [-R|--recursive]'
.' [-q|--quiet]'
.' [-r|--revision REV]'
#
.' [--username USER]'
.' [--password PASS]'
.' [--no-auth-cache]'
.' [--non-interactive]'
.' [--trust-server-cert]' # 1.6
.' [--config-dir DIR]'
.' [--config-option ARG]' # 1.6
.' PROPNAME [PATHORURL...]')},
'relocate' => { # 1.7
args => (''
#'relocate FROM-PREFIX TO-PREFIX [PATH...]
#'relocate TO-URL [PATH]
.' [--ignore-externals]'
#
.' [--username USER]'
.' [--password PASS]'
.' [--no-auth-cache]'
.' [--non-interactive]'
.' [--trust-server-cert]'
.' [--config-dir DIR]'
.' [--config-option ARG]'
.' TOFROM [PATHORURL...]')},
'resolve' => {
args => (''
.' [--accept ARG]'
.' [--depth ARG]'
.' [--targets FILENAME]'
.' [-R|--recursive]'
.' [-q|--quiet]'
#
.' [--config-dir DIR]'
.' [--config-option ARG]' # 1.6
.' PATH...')},
'resolved' => {
args => (''
.' [--depth ARG]' # 1.6
.' [--targets FILENAME]'
.' [-R|--recursive]'
.' [-q|--quiet]'
#
.' [--config-dir DIR]'
.' [--config-option ARG]' # 1.6
.' PATH...')},
'revert' => {
args => (''
.' [--changelist ARG]'
.' [--depth ARG]' # 1.6
.' [--targets FILENAME]'
.' [-R|--recursive]'
lib/SVN/S4/Getopt.pm view on Meta::CPAN
# Commands added in S4
'cat-or-mods' => {
s4_addition => 1,
args => (''
.' [PATH...]')},
'fixprop' => {
s4_addition => 1,
args => (''
.' [-q|--quiet]'
.' [-R|--recursive]' # Ignored as is default
.' [-N|--non-recursive]'
.' [--dry-run]'
.' [--personal]'
.' [--no-autoprops]'
.' [--no-keywords]'
.' [--no-ignores]'
.' [PATH...]')},
'help-summary' => {
s4_addition => 1,
args => (''
.'')},
'info-switches' => {
s4_addition => 1,
args => (''
.' [PATH...]')},
'quick-commit' => {
s4_addition => 1,
args => (''
.' [-m|--message TEXT]'
.' [-F|--file FILE]'
.' [-q|--quiet]'
.' [--dry-run]'
.' [-R|--recursive]' # Ignored as is default
.' [-N|--non-recursive]'
.' [PATH...]')},
'snapshot' => {
s4_addition => 1,
args => (''
.' [--no-ignore]'
.' PATH')},
'scrub' => {
s4_addition => 1,
args => (''
.' [-r|--revision REV]'
.' [--url URL]'
.' [-v|--verbose]'
. ' PATH')},
'workpropdel' => {
s4_addition => 1,
args => (''
.' PROPNAME')},
'workpropget' => {
s4_addition => 1,
args => (''
.' PROPNAME')},
'workproplist' => {
s4_addition => 1,
args => (''
.' [--xml]'
.' [-v|--verbose]')},
'workpropset' => {
s4_addition => 1,
args => (''
.' PROPNAME PROPVAL')},
);
#######################################################################
#######################################################################
#######################################################################
sub new {
@_ >= 1 or croak 'usage: SVN::S4::Getopt->new ({options})';
my $class = shift; # Class (Getopt Element)
$class ||= __PACKAGE__;
my $defaults = {pwd=>Cwd::getcwd(),
editor=>($ENV{SVN_EDITOR}||$ENV{VISUAL}||$ENV{EDITOR}||'emacs'),
ssh=>($ENV{SVN_SSH}),
# Ours
fileline=>'Command_Line:0',
};
my $self = {%{$defaults},
defaults=>$defaults,
@_,
};
bless $self, $class;
return $self;
}
#######################################################################
# Option parsing
sub parameter {
my $self = shift;
# Parse a parameter. Return list of leftover parameters
my @new_params = ();
foreach my $param (@_) {
print " parameter($param)\n" if $Debug;
$self->{_parameter_unknown} = 1; # No global parameters
if ($self->{_parameter_unknown}) {
push @new_params, $param;
next;
}
}
return @new_params;
}
#######################################################################
# Accessors
sub commands_sorted {
return (sort (keys %_Args));
}
sub command_arg_text {
my $self = shift;
my $cmd = shift;
return ($_Args{$cmd}{args});
}
sub command_s4_addition {
( run in 0.577 second using v1.01-cache-2.11-cpan-71847e10f99 )