@@ -793,7 +793,7 @@ sub Init {
793
793
_write_json(PROJECT_FILE, \%jsondata );
794
794
795
795
# checkout default config
796
- Set ($jsondata {defaultconfig });
796
+ Checkout ($jsondata {defaultconfig });
797
797
}
798
798
799
799
sub NewConfig {
@@ -881,11 +881,6 @@ sub _remove_arr_items_from_arr {
881
881
}
882
882
}
883
883
}
884
- # foreach my $item (@{$toremove}) {
885
- # my $index = 0;
886
- # $index++ until $src->[$index] eq $item;
887
- # splice(@$src, $index, 1);
888
- # }
889
884
}
890
885
891
886
sub Status {
@@ -948,7 +943,7 @@ sub _install_perl_src_files {
948
943
}
949
944
}
950
945
951
- sub Set {
946
+ sub Checkout {
952
947
my ($cfgname ) = @_ ;
953
948
my $UserProjectConfig = _load_user_project_config();
954
949
if ($UserProjectConfig ) {
@@ -1037,16 +1032,15 @@ sub Set {
1037
1032
$validperl = abs_path($validperl );
1038
1033
$validperl or die " no valid perl found to use for nobuild config" ;
1039
1034
$UserProjectConfig -> {nobuild_perl_bin } = $validperl ;
1040
- print " Set UserProjectConfig to nobuild_perl-bin to $validperl \n " ;
1035
+ print " Checkout UserProjectConfig to nobuild_perl-bin to $validperl \n " ;
1041
1036
}
1042
1037
_write_user_project_config($UserProjectConfig );
1043
1038
print " $0 : Successfully switched to $cfgname \n " ;
1044
1039
}
1045
1040
1046
1041
sub Configure {
1047
1042
my $Configs = _load_apperl_configs();
1048
- my $UserProjectConfig = _load_valid_user_project_config_with_default($Configs ) or die " cannot Configure without valid UserProjectConfig" ;
1049
- my $CurAPPerlName = $UserProjectConfig -> {current_apperl };
1043
+ my ($UserProjectConfig , $CurAPPerlName ) = _load_valid_user_project_config_with_default($Configs ) or die " cannot Configure without valid UserProjectConfig" ;
1050
1044
! exists $UserProjectConfig -> {nobuild_perl_bin } or die " nobuild perl cannot be configured" ;
1051
1045
my $perl_build_dir = $UserProjectConfig -> {configs }{$CurAPPerlName }{perl_build_dir };
1052
1046
$perl_build_dir && -d $perl_build_dir or die " $perl_build_dir is not a directory" ;
@@ -1111,8 +1105,7 @@ sub _find_zip {
1111
1105
sub Build {
1112
1106
my ($zippath ) = @_ ;
1113
1107
my $Configs = _load_apperl_configs();
1114
- my $UserProjectConfig = _load_valid_user_project_config_with_default($Configs ) or die " cannot Build without valid UserProjectConfig" ;
1115
- my $CurAPPerlName = $UserProjectConfig -> {current_apperl };
1108
+ my ($UserProjectConfig , $CurAPPerlName ) = _load_valid_user_project_config_with_default($Configs ) or die " cannot Build without valid UserProjectConfig" ;
1116
1109
my $itemconfig = _load_apperl_config($Configs -> {apperl_configs }, $CurAPPerlName );
1117
1110
my $startdir = abs_path(' ./' );
1118
1111
@@ -1423,7 +1416,7 @@ END_USAGE
1423
1416
elsif ($command eq ' checkout' ) {
1424
1417
scalar (@_ ) == 1 or die (' bad args' );
1425
1418
my $cfgname = $_ [0];
1426
- Perl::Dist::APPerl::Set ($cfgname );
1419
+ Perl::Dist::APPerl::Checkout ($cfgname );
1427
1420
}
1428
1421
elsif ($command eq ' init' ) {
1429
1422
my $usage = <<'END_USAGE' ;
@@ -1661,17 +1654,21 @@ sub _load_valid_user_project_config {
1661
1654
if (exists $UserProjectConfig -> {current_apperl }) {
1662
1655
my $CurAPPerlName = $UserProjectConfig -> {current_apperl };
1663
1656
exists $Configs -> {apperl_configs }{$CurAPPerlName } or die (" non-existent apperl config $CurAPPerlName in user project config" );
1664
- return $UserProjectConfig ;
1657
+ return ( $UserProjectConfig , $CurAPPerlName ) ;
1665
1658
}
1666
1659
}
1667
- return undef ;
1660
+ return () ;
1668
1661
}
1669
1662
1670
1663
sub _load_valid_user_project_config_with_default {
1671
1664
my ($Configs ) = @_ ;
1672
- my $UserProjectConfig = _load_valid_user_project_config($Configs );
1673
- return $UserProjectConfig if ($UserProjectConfig || !exists $Configs -> {defaultconfig });
1674
- Set($Configs -> {defaultconfig });
1665
+ my ($UserProjectConfig , $CurAPPerlName ) = _load_valid_user_project_config($Configs );
1666
+ if ($UserProjectConfig ) {
1667
+ return ($UserProjectConfig , $CurAPPerlName );
1668
+ } elsif (!exists $Configs -> {defaultconfig }) {
1669
+ return ();
1670
+ }
1671
+ Checkout($Configs -> {defaultconfig });
1675
1672
return _load_valid_user_project_config($Configs );
1676
1673
}
1677
1674
0 commit comments