From b88fb075c4485154f72fb72354f8bf8004d71f72 Mon Sep 17 00:00:00 2001 From: Andinus Date: Tue, 2 Mar 2021 23:38:13 +0530 Subject: Print default USAGE, remove shorthand for verbose option The input file format can be explained in the documentation. --- lib/Octans/CLI.rakumod | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'lib/Octans/CLI.rakumod') 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 // "/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 %𝒻𝒶𝓃𝒸𝓎-𝒸𝒽𝒶𝓇𝓈 = ; + my %𝒻𝒶𝓃𝒸𝓎-𝒸𝒽𝒶𝓇𝓈 = + :a, :b, :c, :d, :e, :f, :g, :h, :i, + :j, :k, :l, :m, :n, :o, :p, :q, :r, + :s, :t, :u, :v, :w, :x, :y, :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; } - -multi sub MAIN ( - Bool :h($help) #= print help -) { USAGE(); exit; } -- cgit 1.4.1-2-gfad0