Last active
July 31, 2017 04:20
-
-
Save jerome-diver/934717a282b12c6030829d22fdc3ecd9 to your computer and use it in GitHub Desktop.
Hash and Associative Hash definition and argument functions...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Type check failed in binding to parameter '%failed'; expected Associative[Hash] but got Hash (${}) | |
in sub show_errors at /home/jerome/PROGRAMATION/Perl/vimplugger/check/Check.pm6 (Check) line 54 | |
in sub some_from_group at /home/jerome/PROGRAMATION/Perl/vimplugger/repos/Install.pm6 (Install) line 21 | |
in block at ./VimPlugger.pl6 line 62 | |
in block <unit> at ./VimPlugger.pl6 line 59 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----Install.pm6---- | |
unit module Install; | |
use Prompt::Gruff::Export; | |
use Git::Wrapper; | |
use Check; | |
use Datas; | |
my %q = "select_groups" => "Select some groups of repos you want to install ?", | |
"select_repos" => "Select some repos to install: ", | |
"select_group" => "Choose a group from where you will install some repos: "; | |
###### PUBLIC FUNCTIONS ################################################################## | |
our sub some_from_group($yaml) { | |
say "OK"; | |
my $group_name = Check::choose_group($yaml, ~q<select_group>); | |
my @repo_titles = Check::choose_repos_from($yaml, $group_name, ~%q<select_repos>); | |
my %failed; | |
@repo_titles.map: { install_repo($yaml, $group_name, $_, %failed) }; | |
return Check::show_errors(%failed); | |
} | |
our sub all_from_groups($yaml) { | |
my @groups_names = Check::choose_groups($yaml, ~%q<select_groups>); | |
my $err_flag = 0; | |
my %failed; | |
@groups_names.map: { install_repos_from($yaml, $_, %failed) }; | |
return Check::show_errors(%failed); | |
} | |
our sub all_repos($yaml) { | |
my %failed; | |
my @groups = $yaml.groups(); | |
for @groups -> %group { | |
for %group<repos> -> %repo { | |
install_repo($yaml, %group<group>, %repo<url>, %failed); | |
} | |
} | |
return Check::show_errors(%failed); | |
} | |
##### PRIVATE FUNCTIONS ################################################################## | |
my sub install_repos_from($yaml, Str $group_name is required, | |
%failed is required) { | |
my @answer; | |
my $git = Git::Wrapper.new(gitdir => $yaml.repo_dir); | |
my %group := $yaml.group($group_name); | |
for %group<repos> -> %repo { @answer = $git.run: 'clone', %repo<url>; } | |
} | |
my sub install_repo($yaml, Str $group_name is required, | |
Str $title is required, | |
%failed is required) { | |
my $url = $yaml.url_of($group_name, $title); | |
my $git = Git::Wrapper.new(gitdir => $yaml.repo_dir); | |
my @answer = $git.run: "clone", $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment