@@ -18,36 +18,55 @@ sub new {
1818 my ($class , @argv ) = @_ ;
1919 my $self = bless {}, $class ;
2020
21- $self -> {orig_argv } = [@argv ];
21+ $self -> {orig_argv } = [ @argv ];
22+
23+ # # treat flags only if before the "command"
24+ while (@argv && $argv [0] =~ / ^-/ ) {
25+ $self -> _activate_flag(shift @argv )
26+ }
27+
2228 $self -> {command } = @argv ? lc shift @argv : ' ' ;
23- $self -> {argv } = [@argv ];
2429
30+ $self -> {argv } = [ @argv ];
31+
2532 # handle config
2633 $self -> _do_config;
27-
34+ $self -> _dump_config if $self -> {debug };
35+
2836 return $self ;
2937}
3038
39+ sub _activate_flag {
40+ my ($self , $flag ) = @_ ;
41+ if ($flag eq " -D" ) { $self -> {debug } = 1; }
42+ # FIXME: complin on unknown flags?
43+ }
44+
3145sub run {
3246 my ($self ) = @_ ;
3347
34- if ($self -> {command } eq ' setup' ) { $self -> _do_setup; }
35- elsif ($self -> {command } eq ' perl' ) { $self -> _do_perl; }
48+ if ($self -> {command } eq ' setup' ) { $self -> _do_setup; }
49+ elsif ($self -> {command } eq ' perl' ) { $self -> _do_perl; }
3650 elsif ($self -> {command } eq ' cpanm' ) { $self -> _do_cpanm; }
37- elsif ($self -> {command } eq ' bin' ) { $self -> _do_bin; }
38- elsif ($self -> {command } eq ' run' ) { $self -> _do_run; }
51+ elsif ($self -> {command } eq ' bin' ) { $self -> _do_bin; }
52+ elsif ($self -> {command } eq ' run' ) { $self -> _do_run; }
3953 else { $self -> _do_help; }
4054}
4155
56+ sub _dump_config {
57+ my ($self ) = @_ ;
58+ print STDERR Dumper($self );
59+ }
60+
4261sub _do_config {
4362 my ($self ) = @_ ;
4463
4564 # set some defaults
4665 $self -> {perl } = ' system' ;
4766 $self -> {deps } = ' dzil' ;
4867 $self -> {skip_install } = 1;
49- $self -> {p5stack_root } = catfile($ENV {HOME },' .p5stack' );
50- $self -> {perls_root } = catfile($ENV {HOME },' .p5stack' ,' perls' );
68+ $self -> {p5stack_root } = catfile($ENV {HOME }, ' .p5stack' );
69+ $self -> {perls_root } = catfile($ENV {HOME }, ' .p5stack' , ' perls' );
5170 $self -> {perl_version } = ' 5.20.3' ;
5271
5372 # guess stuff from context
@@ -196,9 +215,10 @@ sub _do_install_perl_release {
196215sub _do_perl {
197216 my ($self ) = @_ ;
198217
199- my $run = join (' ' ,$self -> {perl }, " -I $self ->{Ilib}" ,
200- " -Mlocal::lib" , @{$self -> {argv }});
218+ my $run = join (' ' ,$self -> {perl }, " -I$self ->{Ilib}" ,
219+ " -Mlocal::lib= $self ->{local_lib} " , @{$self -> {argv }});
201220
221+ print STDERR " Running: $run \n " if $self -> {debug };
202222 system $run ;
203223}
204224
0 commit comments