about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-11-04 14:26:49 +0530
committerAndinus <andinus@nand.sh>2021-11-04 14:26:49 +0530
commited7cf1ca81bc7e8ca41ee648fcb13ea438903bc6 (patch)
treeed7199674c6db66753cd599c8d3e2f88a156e66e
parent203ba71bc2b5bded2bc5c4a9e1d889b483e7f30f (diff)
downloadfornax-ed7cf1ca81bc7e8ca41ee648fcb13ea438903bc6.tar.gz
Add option to skip generating slideshow, use random directory
-rw-r--r--lib/Fornax/CLI.rakumod25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/Fornax/CLI.rakumod b/lib/Fornax/CLI.rakumod
index bcecff2..1cf518d 100644
--- a/lib/Fornax/CLI.rakumod
+++ b/lib/Fornax/CLI.rakumod
@@ -2,7 +2,6 @@ use Cairo;
 use Fornax::Hex2RGB;
 
 subset File of Str where *.IO.f;
-subset Directory of Str where *.IO.d;
 
 #| Parses fornax format file to extract metadata.
 grammar Metadata {
@@ -16,10 +15,19 @@ proto MAIN(|) is export { unless so @*ARGS { put $*USAGE; exit }; {*} }
 #| Collection of tools to visualize Path Finding Algorithms
 multi sub MAIN(
     File $input, #= fornax format file (solved)
-    Directory :$output = '/tmp/output', #= output directory (existing)
-    Rat() :$frame-rate = 1, #= frame rate
+    IO() :$out = '/tmp', #= output directory (default: /tmp)
+    Rat() :$frame-rate = 1, #= frame rate (default: 1)
+    Bool :$skip-video, #= skip video solution
     Bool :$verbose = True, #= verbosity
 ) is export {
+    my IO() $output = "%s/fornax-%s".sprintf(
+        $out.absolute, ('a'...'z', 'A'...'Z', 0...9).roll(8).join
+    );
+    mkdir $output;
+    die "Output directory doesn't exist" unless $output.d;
+
+    put "[fornax] Output: '$output'" if $verbose;
+
     my Str @lines = $input.IO.lines;
     my Int() %meta{Str} = Metadata.parse(@lines.first).Hash
                              or die "Cannot parse metadata";
@@ -129,11 +137,14 @@ multi sub MAIN(
     }
 
     put "[fornax] Generated images." if $verbose;
-    put "[fornax] Creating a slideshow." if $verbose;
 
-    my Str $log-level = $verbose ?? "info" !! "error";
-    run «ffmpeg -loglevel "$log-level" -r "$frame-rate" -i "$output/\%08d.png"
-                -vcodec libx264 -crf 28 -pix_fmt yuv420p "$output/solution.mp4"»;
+    unless $skip-video {
+        put "[fornax] Creating a slideshow." if $verbose;
+
+        my Str $log-level = $verbose ?? "info" !! "error";
+        run «ffmpeg -loglevel "$log-level" -r "$frame-rate" -i "$output/\%08d.png"
+                    -vcodec libx264 -crf 28 -pix_fmt yuv420p "$output/solution.mp4"»;
+    }
     put "[fornax] Output: '$output'";
 }