chiark
/
gitweb
/
~ianmdlvl
/
dgit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31995d0
)
Permit defvalopt $fn to be a scalar ref instead (nfc, since no users)
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Fri, 14 Aug 2015 13:13:11 +0000
(14:13 +0100)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Fri, 14 Aug 2015 17:34:59 +0000
(18:34 +0100)
dgit
patch
|
blob
|
history
diff --git
a/dgit
b/dgit
index 4f63f0324b56dea474fbd5beaab182feeb687b32..d4193ccd2e8d8df7da4d5c5460a57ea45176ca24 100755
(executable)
--- a/
dgit
+++ b/
dgit
@@
-3111,14
+3111,15
@@
sub cmd_version {
our (%valopts_long, %valopts_short);
our @rvalopts;
our (%valopts_long, %valopts_short);
our @rvalopts;
-sub defvalopt ($$$
&
) {
- my ($long,$short,$val_re,$
fn
) = @_;
- my $oi = { Long => $long, Short => $short, Re => $val_re,
Fn => $fn
};
+sub defvalopt ($$$
$
) {
+ my ($long,$short,$val_re,$
how
) = @_;
+ my $oi = { Long => $long, Short => $short, Re => $val_re,
How => $how
};
$valopts_long{$long} = $oi;
$valopts_short{$short} = $oi;
$valopts_long{$long} = $oi;
$valopts_short{$short} = $oi;
- # $
fn
subref should:
+ # $
how
subref should:
# do whatever assignemnt or thing it likes with $_[0]
# if the option should not be passed on to remote, @rvalopts=()
# do whatever assignemnt or thing it likes with $_[0]
# if the option should not be passed on to remote, @rvalopts=()
+ # or $how can be a scalar ref, meaning simply assign the value
}
defvalopt '--since-version', '-v', '[^_]+|_', sub {
}
defvalopt '--since-version', '-v', '[^_]+|_', sub {
@@
-3148,7
+3149,12
@@
sub parseopts () {
}
badusage "bad value \`$val' for $what" unless
$val =~ m/^$oi->{Re}$(?!\n)/s;
}
badusage "bad value \`$val' for $what" unless
$val =~ m/^$oi->{Re}$(?!\n)/s;
- $oi->{Fn}($val);
+ my $how = $oi->{How};
+ if (ref($how) eq 'SCALAR') {
+ $$how = $val;
+ } else {
+ $how->($val);
+ }
push @ropts, @rvalopts;
};
push @ropts, @rvalopts;
};