Skip to content

Commit ad653ba

Browse files
committed
rename cmd to run, dwim more on multi
1 parent 898bf10 commit ad653ba

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

bin/plx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ sub run_action_which {
390390
say join(' ', 'plx', "--${action}", @call);
391391
}
392392

393-
sub run_action_cmd {
393+
sub run_action_run {
394394
my ($self, @args) = @_;
395395
my ($action, @call) = $self->_which(@args);
396396
$self->${\"run_action_${action}"}(@call);
@@ -581,11 +581,12 @@ sub _parse_multi {
581581
my ($self, @args) = @_;
582582
my @multi;
583583
MULTI: while (@args) {
584-
barf "Expected multi arg [, got: $args[0]" unless $args[0] eq '[';
584+
barf "Expected multi arg {, got: $args[0]" unless $args[0] eq '{';
585585
shift @args;
586586
my @action;
587+
/^--/ or s/^/--/ for @args ? $args[0] : ();
587588
while (my $el = shift @args) {
588-
push @multi, \@action and next MULTI if $el eq ']';
589+
push @multi, \@action and next MULTI if $el eq '}';
589590
push @action, $el;
590591
}
591592
barf "Missing closing ] for multi";
@@ -618,7 +619,7 @@ sub run_action_showmulti {
618619
sub run {
619620
my ($self, $cmd, @args) = @_;
620621
$cmd ||= '--help';
621-
if ($cmd eq '[') {
622+
if ($cmd eq '{') {
622623
return $self->run_action_multi($cmd, @args);
623624
}
624625
if ($cmd =~ s/^--//) {
@@ -632,7 +633,7 @@ sub run {
632633
$cmd = shift @args;
633634
}
634635
$self->ensure_layout_config_dir;
635-
return $self->run_action_cmd($cmd, @args);
636+
return $self->run_action_run($cmd, @args);
636637
}
637638

638639
caller() ? 1 : __PACKAGE__->new->run(@ARGV);
@@ -818,7 +819,7 @@ a modified C<--cpanm> action that uses an inline C<App::cpanminus>.
818819
plx --exec <cmd> <args> # exec()s with env vars set
819820
plx --perl <args> # Run perl with args
820821
821-
plx --cmd <cmd> <args> # DWIM command:
822+
plx --run <cmd> <args> # DWIM command:
822823
823824
cmd = perl -> --perl <args>
824825
cmd = -<flag> -> --perl -<flag> <args>
@@ -830,15 +831,15 @@ a modified C<--cpanm> action that uses an inline C<App::cpanminus>.
830831
exists bin/<name> -> --perl bin/<name> <args>
831832
else -> --exec <name> <args>
832833
833-
plx --which <cmd> # Expands --cmd <cmd> without running
834+
plx --which <cmd> # Expands --run <cmd> without running
834835
835-
plx <something> <args> # Shorthand for plx --cmd
836+
plx <something> <args> # Shorthand for plx --run
836837
837838
plx --commands <filter>? # List available commands
838839
839-
plx --multi [ <cmd1> <args1> ] [ ... ] # Run multiple actions
840-
plx --showmulti [ ... ] [ ... ] # Show multiple action running
841-
plx [ ... ] [ ... ] # Shorthand for plx --multi
840+
plx --multi { <cmd1> <args1> } { ... } # Run multiple actions
841+
plx --showmulti { ... } { ... } # Show multiple action running
842+
plx { ... } { ... } # Shorthand for plx --multi
842843
843844
plx --userinit <perl> # Init ~/.plx with ~/perl5 ll
844845
plx --installself # Installs plx and cpanm into layout
@@ -949,9 +950,9 @@ Without arguments, sugar for C<--config perl>.
949950
Otherwise, sets up the layout's environment variables and C<exec>s the
950951
layout's perl with the given options and arguments.
951952
952-
=head2 --cmd
953+
=head2 --run
953954
954-
plx --cmd <cmd> <args>
955+
plx --run <cmd> <args>
955956
956957
cmd = perl -> --perl <args>
957958
cmd = -<flag> -> --perl -<flag> <args>
@@ -977,7 +978,7 @@ anything with a non-perl shebang, one can add wrappers here ala:
977978
978979
plx --which <cmd>
979980
980-
Outputs the expanded form of a C<--cmd> invocation without running it.
981+
Outputs the expanded form of a C<--run> invocation without running it.
981982
982983
=head2 --config
983984
@@ -1060,13 +1061,15 @@ stripped and the filter is treated as a regexp.
10601061
10611062
=head2 --multi
10621063
1063-
plx --multi [ --init ] [ --config perl set 5.28.0 ]
1064+
plx --multi { --init } { --config perl set 5.28.0 }
1065+
plx --multi { init } { config perl set 5.28.0 }
10641066
10651067
Runs multiple plx commands from a single invocation delimited by C<[ ... ]>.
10661068
10671069
=head2 --showmulti
10681070
1069-
plx --showmulti [ --init ] [ --config perl set 5.28.0 ]
1071+
plx --showmulti { --init } { --config perl set 5.28.0 }
1072+
plx --showmulti { init } { config perl set 5.28.0 }
10701073
10711074
Outputs approximate plx invocations that would be run by C<--multi>.
10721075

t/basic.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ subtest 'no .plx', sub {
4141
reset_var_dir;
4242
ok(do{ eval { plx "--$_" }; @$err }, "no init: --$_ failed") for qw(
4343
base
44-
cmd
44+
run
4545
commands
4646
config
4747
cpanm
@@ -60,12 +60,12 @@ plx_subtest 'plx --actions', sub {
6060
like $err->[0], qr/No such action --actions/, 'not an action; see perldoc';
6161
};
6262

63-
plx_subtest 'plx --cmd', sub {
64-
plx qw(--cmd echo 'ehlo');
63+
plx_subtest 'plx --run', sub {
64+
plx qw(--run echo 'ehlo');
6565
is_deeply $log, ['echo', "'ehlo'"];
66-
plx qw(--cmd perl -MData::Dumper=Dumper -E 'Dumper(@ARGV)');
66+
plx qw(--run perl -MData::Dumper=Dumper -E 'Dumper(@ARGV)');
6767
is_deeply $log, [$path_perl, '-MData::Dumper=Dumper', '-E', "'Dumper(\@ARGV)'"];
68-
# plx qw(--cmd /usr/local/bin/psql postgres);
68+
# plx qw(--run /usr/local/bin/psql postgres);
6969
# is_deeply $log, ['/usr/local/bin/psql', 'postgres'];
7070
};
7171

0 commit comments

Comments
 (0)