diff --git a/bin/air-examples b/bin/air-examples new file mode 100644 index 0000000..a6462f3 --- /dev/null +++ b/bin/air-examples @@ -0,0 +1,2 @@ +use v6.d; +use Air::Examples; diff --git a/lib/Air/Examples.rakumod b/lib/Air/Examples.rakumod index 1313523..fa6f3ba 100644 --- a/lib/Air/Examples.rakumod +++ b/lib/Air/Examples.rakumod @@ -1,6 +1,25 @@ use v6.d; +use Term::Choose; -module Examples { - # deliberately empty - # just run a script in /bin +unit module Examples; +=begin rakudoc +Get the examples from the bin file and allow for a choice +=end rakudoc +multi sub MAIN { + my $this = 'Air-examples.raku'; + my $ex-dir = 'x-bin'; + + my @examples = $ex-dir.IO.dir(test=>/'.raku'/)>>.basename.grep({ !m/$this/ }).sort; + my $tc = Term::Choose.new( + :1mouse, + :0order, + :2color, + :0clear-screen + ); + + my $chosen; + my $proc; + $chosen = $tc.choose( @examples, :2layout, :0default ); + say "Running example: $chosen\nUse Ctr-C to stop server"; + $proc = run ($*EXECUTABLE, '-I.', "$ex-dir/$chosen"); }