Skip to content

Commit

Permalink
Merge pull request #107 from dwarring/master
Browse files Browse the repository at this point in the history
adding 'look' command - fetch, then invoke shell in temporary directory
  • Loading branch information
lizmat committed Oct 21, 2014
2 parents c1fd655 + 704557a commit 1ff9959
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
12 changes: 11 additions & 1 deletion bin/panda
Expand Up @@ -17,7 +17,7 @@ my $panda = Panda.new(:ecosystem(make-default-ecosystem));
multi MAIN ('install', *@modules, Bool :$notests, Bool :$nodeps) {
for @modules -> $x {
try {
$panda.resolve($x, :$notests, :$nodeps);
$panda.resolve($x, :$notests, :$nodeps, :action<install>);
CATCH { when X::Panda { say $_.message } }
};
}
Expand All @@ -43,6 +43,16 @@ multi MAIN ('search', $pattern) {
search-projects($panda, $pattern);
}

#= Download and unpack the distribution and then open the directory with your shell.
multi MAIN ('look', *@modules) {
for @modules -> $x {
try {
$panda.resolve($x, :notests, :action<look>);
CATCH { when X::Panda { say $_.message } }
};
}
}

END {
rm_rf '.panda-work' if '.panda-work'.IO.e;
}
Expand Down
33 changes: 31 additions & 2 deletions lib/Panda.pm
Expand Up @@ -77,6 +77,31 @@ class Panda {
return False;
}

method look(Panda::Project $bone) {
my $dir = tmpdir();

self.announce('fetching', $bone);
unless $bone.metainfo<source-url> {
die X::Panda.new($bone.name, 'fetch', 'source-url meta info missing')
}
unless $_ = $.fetcher.fetch($bone.metainfo<source-url>, $dir) {
die X::Panda.new($bone.name, 'fetch', $_)
}

my $shell = %*ENV<SHELL>;
$shell ||= %*ENV<COMSPEC>
if $*DISTRO.name eq 'mswin32';

if $shell {

my $*CWD = $dir;
self.announce("Entering $dir with $shell\n");
shell $shell or fail "Unable to invoke shell: $shell"
} else {
self.announce("You don't seem to have a SHELL");
}
}

method install(Panda::Project $bone, $nodeps,
$notests, $isdep as Bool) {
my $cwd = $*CWD;
Expand Down Expand Up @@ -131,7 +156,7 @@ class Panda {
return @deps;
}

method resolve($proj as Str is copy, Bool :$nodeps, Bool :$notests) {
method resolve($proj as Str is copy, Bool :$nodeps, Bool :$notests, :$action='install') {
my $tmpdir = tmpdir();
LEAVE { rm_rf $tmpdir if $tmpdir.IO.e }
mkpath $tmpdir;
Expand Down Expand Up @@ -160,7 +185,11 @@ class Panda {
};
self.install($_, $nodeps, $notests, 1) for @deps;
}
self.install($bone, $nodeps, $notests, 0);

given $action {
when 'install' { self.install($bone, $nodeps, $notests, 0); }
when 'look' { self.look($bone) };
}
}
}

Expand Down

0 comments on commit 1ff9959

Please sign in to comment.