summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2015-08-14 14:13:11 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2015-08-14 18:34:59 +0100
commit0806f3412f73bbfe32f0f57504c3fff200247a0a (patch)
tree46dab890ec7126f7825cc34f7f335eeb241afc65
parent31995d0c8b6212275829a7e432821d5d94633ef5 (diff)
Permit defvalopt $fn to be a scalar ref instead (nfc, since no users)
-rwxr-xr-xdgit16
1 files changed, 11 insertions, 5 deletions
diff --git a/dgit b/dgit
index 4f63f03..d4193cc 100755
--- a/dgit
+++ b/dgit
@@ -3111,14 +3111,15 @@ sub cmd_version {
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;
- # $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=()
+ # or $how can be a scalar ref, meaning simply assign the value
}
defvalopt '--since-version', '-v', '[^_]+|_', sub {
@@ -3148,7 +3149,12 @@ sub parseopts () {
}
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;
};