Skip to content

Commit 2837d87

Browse files
committed
add --dev action
1 parent 726e8bd commit 2837d87

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

bin/plx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,39 @@ sub run_action_cmd {
284284
$self->run_action_exec($cmd, @args);
285285
}
286286

287+
sub run_action_dev {
288+
my ($self) = @_;
289+
$self->ensure_layout_config_dir;
290+
291+
unless (-d (my $dir = $self->layout_dir('dev'))) {
292+
mkdir($dir) or die "Couldn't make script dir ${dir}: $!";
293+
my $file = $self->layout_file('dev', 'find');
294+
open my $wfh, '>', $file or die "Couldn't open ${file}: $!";
295+
print $wfh <<'EOF';
296+
#!perl
297+
298+
use feature 'say';
299+
use File::Basename 'basename';
300+
use File::Spec::Functions 'catfile';
301+
302+
my $in = $ARGV[0] || '.*';
303+
304+
map say(basename($_)), grep /$in/, map glob(catfile($_, '*')), grep -d, qw(
305+
./bin
306+
./dev
307+
./local/bin
308+
./script
309+
./scripts
310+
);
311+
EOF
312+
stderr <<END;
313+
.plx script directory [dev] initialised with script [find]:
314+
315+
plx find <arg>
316+
END
317+
}
318+
}
319+
287320
sub run_action_perl {
288321
my ($self, @call) = @_;
289322
$self->ensure_layout_config_dir;
@@ -621,6 +654,7 @@ a modified C<--cpanm> action that uses an inline C<App::cpanminus>.
621654
plx --init <perl> # Initialize layout config for .
622655
plx --base # Show layout base dir
623656
plx --base <base> <action> <args> # Run action with specified base dir
657+
plx --dev # Initialize (dev) script dir
624658
625659
plx --perl # Show layout perl binary
626660
plx --libs # Show layout $PERL5LIB entries
@@ -753,6 +787,19 @@ Without arguments, sugar for C<--config perl>.
753787
Otherwise, sets up the layout's environment variables and C<exec>s the
754788
layout's perl with the given options and arguments.
755789
790+
=head2 --dev
791+
792+
plx --dev
793+
794+
Initializes the ./dev script directory with ./dv/find.
795+
796+
There are various common directories which are searched in order to resolve
797+
script execution including the C<dev> directory. You can add your own scripts
798+
to any of these directories and have C<plx> find and execute them. Unless the
799+
C<dev> directory already exists in the current working directory, this command
800+
creates that directory and seeds it with a C<find> script that helps you see
801+
what scripts are available across these directories.
802+
756803
=head2 --cmd
757804
758805
plx --cmd <cmd> <args> # DWIM command:

0 commit comments

Comments
 (0)