about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Octans/CLI.rakumod34
1 files changed, 10 insertions, 24 deletions
diff --git a/lib/Octans/CLI.rakumod b/lib/Octans/CLI.rakumod
index ee7c5c7..3e15dcf 100644
--- a/lib/Octans/CLI.rakumod
+++ b/lib/Octans/CLI.rakumod
@@ -1,15 +1,15 @@
 use Octans::Puzzle;
 use Octans::WordSearch;
 
-proto MAIN (|) is export {unless so @*ARGS {USAGE(); exit;}; {*}}
+proto MAIN (|) is export { unless so @*ARGS { say $*USAGE; exit }; {*} }
 
 multi sub MAIN (
     Str $path, #= path to the crossword (file or url)
     Str :$dict = (%?RESOURCES<mwords/354984si.ngl> //
                   "/usr/share/dict/words").Str, #= dictionary file
     Int :$length = 7, #= minimum word length (default: 7)
-    Bool :v($verbose), #= increase verbosity
-) {
+    Bool :$verbose, #= increase verbosity
+) is export {
     # @dict holds the sorted dictionary. Only consider words >= 7
     # chars by default.
     my Str @dict = $dict.IO.lines.grep(*.chars >= $length);
@@ -43,9 +43,10 @@ multi sub MAIN (
 
     # After the solution is found, the path is printed with these
     # fancy chars.
-    my %𝒻𝒶𝓃𝒸𝓎-𝒸𝒽𝒶𝓇𝓈 = <a a̶ b b̶ c c̶ d d̶ e e̶ f f̶ g g̶ h h̶ i i̶ j j̶ k k̶ l l̶
-                         m m̶ n n̶ o o̶ p p̶ q q̶ r r̶ s s̶ t t̶ u u̶ v v̶ w w̶ x
-                         x̶ y y̶ z z̶>;
+    my %𝒻𝒶𝓃𝒸𝓎-𝒸𝒽𝒶𝓇𝓈 =
+    :a<a̶>, :b<b̶>, :c<c̶>, :d<d̶>, :e<e̶>, :f<f̶>, :g<g̶>, :h<h̶>, :i<i̶>,
+    :j<j̶>, :k<k̶>, :l<l̶>, :m<m̶>, :n<n̶>, :o<o̶>, :p<p̶>, :q<q̶>, :r<r̶>,
+    :s<s̶>, :t<t̶>, :u<u̶>, :v<v̶>, :w<w̶>, :x<x̶>, :y<y̶>, :z<z̶>;
 
     # start-pos block loops over each starting position.
     start-pos: for @gray-squares -> $pos {
@@ -72,9 +73,9 @@ multi sub MAIN (
                     print " " x 3;
                     for ^@puzzle[$y].elems -> $x {
                         print " ", (
-                        @visited[$y][$x] ??
-                        (%𝒻𝒶𝓃𝒸𝓎-𝒸𝒽𝒶𝓇𝓈{@puzzle[$y][$x]} // @puzzle[$y][$x]) !!
-                        @puzzle[$y][$x]
+                        @visited[$y][$x]
+                        ?? (%𝒻𝒶𝓃𝒸𝓎-𝒸𝒽𝒶𝓇𝓈{@puzzle[$y][$x]} // @puzzle[$y][$x])
+                        !! @puzzle[$y][$x]
                     );
                     }
                     print "\n";
@@ -84,21 +85,6 @@ multi sub MAIN (
     }
 }
 
-# Modify USAGE to include input file format.
-sub USAGE {
-    say $*USAGE;
-    say "\nInput file format:
-
-    n a t k
-    i m e c
-    a* r d e
-    t* e c h";
-}
-
 multi sub MAIN (
     Bool :$version #= print version
 ) { say "Octans v" ~ $?DISTRIBUTION.meta<version>; }
-
-multi sub MAIN (
-    Bool :h($help) #= print help
-) { USAGE(); exit; }