instow

:)
git clone https://git.sr.ht/~ashymad/instow
Log | Files | Refs | LICENSE

commit 8ae98e8495ba3fe156074df98f43a7510ec7b75b
parent 5aea1f385550ed0906ddf0a8af1e8c50f19f411b
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date:   Wed, 24 Sep 2025 21:03:48 +0200

Up

Diffstat:
Dbug.janet | 11-----------
Minstowl | 2+-
Minstowl.janet | 49++++++++++++++++++++++++++++++-------------------
3 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/bug.janet b/bug.janet @@ -1,11 +0,0 @@ -#!/usr/bin/env janet - -(defn main - [& args] - ((def proc (os/spawn ["echo" "1234567890"] :p {:out :pipe})) - (ev/gather - (do - (var buf @"") - (while (ev/read (proc :out) 1 buf) (print buf) (set buf @""))) - (os/proc-wait proc)) - (os/proc-close proc))) diff --git a/instowl b/instowl @@ -3,7 +3,7 @@ shopt -s dotglob export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig/ -export CFLAGS="-I$HOME/.local/include" +export CFLAGS="-idirafter $HOME/.local/include" export PERL5LIB="$HOME/.local/lib/perl5/" state="init" diff --git a/instowl.janet b/instowl.janet @@ -1,28 +1,39 @@ #!/usr/bin/env janet +(def spinner "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏") + (defn rotate [ch] - (if (= ch "-") "\\" (if (= ch "\\") "|" (if (= ch "|") "/" "-")))) + (def nxt (+ 3 (string/find ch spinner))) + (if (= nxt (length spinner)) (string/slice spinner 0 3) (string/slice spinner nxt (+ nxt 3)))) + +(defn runp + [& args] + (def proc (os/spawn args : {:out :pipe})) + (var ch (string/slice spinner 0 3)) + (ev/gather + (do + (def buf @"") + (while (ev/read (proc :out) 1024 buf) + (def lines (string/split "\n" buf)) + (def len (length lines)) + (if (> len 1) + (loop [[idx line] :pairs lines] + (if (< idx (- len 1)) + (do + (prinf "\x1b[2K\r⸉%s⸊→%s" ch line) + (flush)) + (do (buffer/clear buf) (buffer/push-string buf line))))))) + (os/proc-wait proc) + (while (= (get proc :return-code) nil) (ev/sleep 0.1) (set ch (rotate ch)))) + (def code (get proc :return-code)) + (os/proc-close proc) + code) (defn main [& args] - ((def proc (os/spawn ["./configure"] : {:out :pipe})) - (ev/gather - (do - (def buf @"") - (var ch "-") - (while (ev/read (proc :out) 1024 buf) - (def lines (string/split "\n" buf)) - (def len (length lines)) - (if (> len 1) - (loop [[idx line] :pairs lines] - (if (< idx (- len 1)) - (do - (prinf "\x1b[2K\r[%s] %s" ch line) - (set ch (rotate ch)) - (flush)) - (buffer/blit buf line)))))) - (os/proc-wait proc)) - (os/proc-close proc))) + (if (= (runp "./configure") 0) + (printf "\x1b[2K\r⸉x⸊→Done") + (printf "\x1b[2K\r⸉!⸊→Error")))