Skip to content

Commit

Permalink
added 'showdeps' subcommand
Browse files Browse the repository at this point in the history
Only works if the module is downloaded. I don't see an easy way around that.

The operative part of the showdeps sub could be factored out into a method
that returns a list of dependencies. This method could then be used in the
build process.
  • Loading branch information
Carl Masak committed Feb 16, 2009
1 parent 14bcfc2 commit e4f41a3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions installer
Expand Up @@ -28,6 +28,7 @@ given @*ARGS.shift {
when 'test' { test( @*ARGS) }
when 'update' { update( @*ARGS) }
when 'uninstall' { uninstall(@*ARGS) }
when 'showdeps' { showdeps( @*ARGS) }
default { say "Unrecognized subcommand '$_'. See the README." }
}

Expand Down Expand Up @@ -126,6 +127,38 @@ sub uninstall(*@projects) {
not_implemented('uninstall');
}

sub showdeps(*@projects) {
unless @projects {
say "You have to specify which projects' dependencies to show.";
exit 1;
}
for @projects -> $project {
if $project !~~ :d {
say "$project is not installed.";
next;
}
my $deps_file = $project~'/deps.proto';
if $deps_file !~~ :e {
say "$project has no dependencies.";
next;
}
my &remove_line_ending_comment = { .subst(/ '#' .* $ /, '') };
my &line_is_nonempty = { $^line !~~ / ^ \s* $ / };
my @deps = slurp($deps_file)\
.split("\n")\
.map({remove_line_ending_comment($^line)})\
.grep({line_is_nonempty($^line)});
if !@deps {
say "$project has no dependencies.";
next;
}
say $project, ':';
for @deps -> $dep {
say ' ', $dep;
}
}
}

sub not_implemented($subcommand) {
warn "The '$subcommand' subcommand is not implemented yet.";
}

0 comments on commit e4f41a3

Please sign in to comment.