Permalink
Browse files

[bin/yapsi] slight refactor

Changed sub signature, and the way the prompt looks.
  • Loading branch information...
1 parent 14fa691 commit 5f235c476a2ebc1f5727ab84f795246cf955dcb7 @masak committed Mar 6, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 bin/yapsi
View
@@ -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 {
@@ -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.