Skip to content

Commit 8ed4110

Browse files
committed
Start prototype for CLI
1 parent e412a34 commit 8ed4110

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Makefile.PL

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ WriteMakefile(
3737
'YAML::Tiny' => '1.74',
3838
'URL::Encode' => '0.03',
3939
},
40-
text => { TESTS => 't/*.t t/*/*.t it/*.t it/*/*.t' }
40+
EXE_FILES => ['bin/slick'],
41+
test => { TESTS => 't/*.t t/*/*.t it/*.t it/*/*.t' }
4142
);

bin/slick

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.036;
4+
use utf8;
5+
6+
use File::Basename;
7+
use Cwd qw(getcwd);
8+
use Scalar::Util qw(reftype);
9+
use DDP;
10+
11+
my $valid_verbs = [qw(run generate module)];
12+
my $verb = shift;
13+
my $lib_dir = getcwd . '/lib';
14+
15+
(
16+
say
17+
"Invalid command '$verb' type 'slick help' for a list of the valid commands."
18+
&& exit 1 )
19+
unless grep { $_ eq $verb } $valid_verbs->@*;
20+
21+
my $noun = shift;
22+
23+
unless ($noun) {
24+
say qq{No noun provided, please provide a noun for the command: '$verb'};
25+
26+
if ( $verb eq 'run' ) {
27+
say qq{Perhaps you meant something like: 'slick run app.pl'?};
28+
}
29+
elsif ( $verb eq 'generate' ) {
30+
say
31+
qq{Perhaps you meant something like: 'slick generate router MyApp::Router::ItemRouter'};
32+
}
33+
34+
exit 1;
35+
}
36+
37+
if ( $verb eq 'run' ) {
38+
do( rindex( $noun, '/', 0 ) == 0 ? $noun : './' . $noun );
39+
wait && exit 0;
40+
}
41+
42+
unless ( -d $lib_dir ) {
43+
say qq{Could not find directory: $lib_dir};
44+
say 'Please create this directory to continue.';
45+
exit 1;
46+
}

0 commit comments

Comments
 (0)