Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[bin/yapsi] slight refactor
Changed sub signature, and the way the prompt looks.
  • Loading branch information
Carl Masak committed Mar 6, 2011
1 parent 14fa691 commit 5f235c4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bin/yapsi
Expand Up @@ -5,7 +5,7 @@ use Yapsi;

my @TARGETS = <run future sic>;

sub run-code($target, $program) {
sub run-code($program, :$target) {
try {
my @output;
given Yapsi::Compiler.new {
Expand Down Expand Up @@ -41,14 +41,17 @@ if @*ARGS && @*ARGS[0] ~~ /'--target='(\w+)/ {
}

if @*ARGS == 2 && @*ARGS[0] eq '-e' {
run-code $target, @*ARGS[1];
run-code(@*ARGS[1], :$target);
}
elsif @*ARGS == 1 {
run-code $target, slurp(@*ARGS[0]);
run-code(slurp(@*ARGS[0]), :$target);
}
elsif @*ARGS == 0 {
while prompt("yapsi> ") -> $code { run-code($target, $code) };
while prompt(">>> ") -> $program {
run-code($program, :$target);
}
}
else {
die "Usage: `$*PROGRAM_NAME <file>` or `$*PROGRAM_NAME -e '<program>'`";
die
"Usage: `$*PROGRAM_NAME \[<file>\]` or `$*PROGRAM_NAME -e '<program>'`";
}

0 comments on commit 5f235c4

Please sign in to comment.