tools

various tools I have been using throughout the years
Log | Files | Refs | README | LICENSE

commit 1c18143de8ce8c88e3a0e1b303d93e8e458fbb42
parent 68a0e61661c30964596d7a026d7b80157700f492
Author: mtmn <miro@haravara.org>
Date:   Fri,  7 Aug 2026 22:49:09 +0200

redo to knit

Diffstat:
M.gitignore | 6+++---
Dall.do | 9---------
Dbin/dam.do | 5-----
Dbin/default.do | 39---------------------------------------
Dbin/diggah.do | 8--------
Dbin/hue.do | 9---------
Dbin/kundali.do | 8--------
Dbin/lastfm_rs.do | 5-----
Dbin/lazymaster.do | 8--------
Dbin/nts.do | 8--------
Dbin/plants.do | 5-----
Dbin/pmn.do | 4----
Dbin/pracomer.do | 4----
Dbin/reflink-snap.do | 9---------
Dbin/shuffle.do | 8--------
Dbin/speediness.do | 4----
Dbin/venv-stamp.do | 5-----
Dbin/wrd.do | 7-------
Mjustfile | 16++++++++--------
Aknitfile | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20 files changed, 105 insertions(+), 156 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,7 +1,7 @@ -# redo -.redo/ +# knit +.knit/ +.venv-stamp bin/* -!bin/*.do # python .venv/ # zig diff --git a/all.do b/all.do @@ -1,9 +0,0 @@ -exec >&2 -redo-ifchange \ - bin/dam bin/lastfm_rs bin/plants \ - bin/pmn bin/pracomer bin/speediness \ - bin/wrd \ - bin/mpd_add_to_playlist bin/mpd_add_to_queue bin/mpd_edit_queue \ - bin/mpd_update_library bin/mpd_update_queue \ - bin/diggah bin/lazymaster bin/nts bin/shuffle bin/kundali \ - bin/hue bin/reflink-snap diff --git a/bin/dam.do b/bin/dam.do @@ -1,5 +0,0 @@ -exec >&2 -redo-ifchange ../Cargo.toml ../Cargo.lock ../rust-toolchain.toml \ - ../.cargo/config.toml ../dam/Cargo.toml $(find ../dam/src -name '*.rs') -(cd .. && cargo build --release -p dam) -cp ../target/release/dam "$3" diff --git a/bin/default.do b/bin/default.do @@ -1,39 +0,0 @@ -# Catch-all: builds the mpd_* C binaries from ../mpd/<name>.c. -exec >&2 -case "$1" in -mpd_*) ;; -*) - echo "bin/default.do: no rule to build '$1'" - exit 1 - ;; -esac -redo-ifchange "../mpd/$1.c" -/usr/bin/cc \ - -Wall \ - -Wextra \ - -O2 \ - -march=native \ - -mtune=native \ - -fanalyzer \ - -Wshadow \ - -fstack-protector-strong \ - -D_FORTIFY_SOURCE=2 \ - -fPIE \ - -Wformat \ - -Werror=format-security \ - -Wnull-dereference \ - -Wdangling-pointer \ - -Wtrampolines \ - -Walloca \ - -Wcast-align=strict \ - -Wdate-time \ - -Wfloat-equal \ - -Wpointer-arith \ - -Wredundant-decls \ - -Wswitch-default \ - -Wvla \ - -Wwrite-strings \ - -o "$3" "../mpd/$1.c" \ - -lmpdclient \ - -Wl,-z,relro \ - -Wl,-z,now diff --git a/bin/diggah.do b/bin/diggah.do @@ -1,8 +0,0 @@ -exec >&2 -redo-ifchange venv-stamp ../diggah/diggah.py -root=$(cd .. && pwd) -cat > "$3" <<EOF -#!/bin/sh -exec "$root/.venv/bin/python" "$root/diggah/diggah.py" "\$@" -EOF -chmod +x "$3" diff --git a/bin/hue.do b/bin/hue.do @@ -1,8 +0,0 @@ -exec >&2 -redo-ifchange ../hue/bin/hue $(find ../hue/lib -name '*.rb') -root=$(cd .. && pwd) -cat > "$3" <<EOF -#!/bin/sh -exec ruby -I"$root/hue/lib" "$root/hue/bin/hue" "\$@" -EOF -chmod +x "$3" -\ No newline at end of file diff --git a/bin/kundali.do b/bin/kundali.do @@ -1,8 +0,0 @@ -exec >&2 -redo-ifchange venv-stamp ../kundali/kundali.py -root=$(cd .. && pwd) -cat > "$3" <<EOF -#!/bin/sh -exec "$root/.venv/bin/python" "$root/kundali/kundali.py" "\$@" -EOF -chmod +x "$3" diff --git a/bin/lastfm_rs.do b/bin/lastfm_rs.do @@ -1,5 +0,0 @@ -exec >&2 -redo-ifchange ../Cargo.toml ../Cargo.lock ../rust-toolchain.toml \ - ../.cargo/config.toml ../lastfm_rs/Cargo.toml $(find ../lastfm_rs/src -name '*.rs') -(cd .. && cargo build --release -p lastfm_rs) -cp ../target/release/lastfm_rs "$3" diff --git a/bin/lazymaster.do b/bin/lazymaster.do @@ -1,8 +0,0 @@ -exec >&2 -redo-ifchange venv-stamp ../lazymaster/lazymaster.py -root=$(cd .. && pwd) -cat > "$3" <<EOF -#!/bin/sh -exec "$root/.venv/bin/python" "$root/lazymaster/lazymaster.py" "\$@" -EOF -chmod +x "$3" diff --git a/bin/nts.do b/bin/nts.do @@ -1,8 +0,0 @@ -exec >&2 -redo-ifchange venv-stamp ../nts/nts.py -root=$(cd .. && pwd) -cat > "$3" <<EOF -#!/bin/sh -exec "$root/.venv/bin/python" "$root/nts/nts.py" "\$@" -EOF -chmod +x "$3" diff --git a/bin/plants.do b/bin/plants.do @@ -1,5 +0,0 @@ -exec >&2 -redo-ifchange ../Cargo.toml ../Cargo.lock ../rust-toolchain.toml \ - ../.cargo/config.toml ../plants/Cargo.toml $(find ../plants/src -name '*.rs') -(cd .. && cargo build --release -p plants) -cp ../target/release/plants "$3" diff --git a/bin/pmn.do b/bin/pmn.do @@ -1,4 +0,0 @@ -exec >&2 -redo-ifchange ../pmn/build.zig ../pmn/build.zig.zon $(find ../pmn/src -name '*.zig') -(cd ../pmn && zig build -Doptimize=ReleaseSafe) -cp ../pmn/zig-out/bin/pmn "$3" diff --git a/bin/pracomer.do b/bin/pracomer.do @@ -1,4 +0,0 @@ -exec >&2 -redo-ifchange ../pracomer/build.zig ../pracomer/build.zig.zon $(find ../pracomer/src -name '*.zig') -(cd ../pracomer && zig build -Doptimize=ReleaseSafe) -cp ../pracomer/zig-out/bin/pracomer "$3" diff --git a/bin/reflink-snap.do b/bin/reflink-snap.do @@ -1,8 +0,0 @@ -exec >&2 -redo-ifchange ../reflink-snap/reflink-snap.rb -root=$(cd .. && pwd) -cat > "$3" <<EOF -#!/bin/sh -exec ruby "$root/reflink-snap/reflink-snap.rb" "\$@" -EOF -chmod +x "$3" -\ No newline at end of file diff --git a/bin/shuffle.do b/bin/shuffle.do @@ -1,8 +0,0 @@ -exec >&2 -redo-ifchange venv-stamp ../shuffle/shuffle.py -root=$(cd .. && pwd) -cat > "$3" <<EOF -#!/bin/sh -exec "$root/.venv/bin/python" "$root/shuffle/shuffle.py" "\$@" -EOF -chmod +x "$3" diff --git a/bin/speediness.do b/bin/speediness.do @@ -1,4 +0,0 @@ -exec >&2 -redo-ifchange ../speediness/build.zig ../speediness/build.zig.zon $(find ../speediness/src -name '*.zig') -(cd ../speediness && zig build -Doptimize=ReleaseSafe) -cp ../speediness/zig-out/bin/speediness "$3" diff --git a/bin/venv-stamp.do b/bin/venv-stamp.do @@ -1,5 +0,0 @@ -exec >&2 -redo-ifchange ../requirements.txt -python3 -m venv ../.venv -../.venv/bin/pip install --quiet --require-hashes -r ../requirements.txt -sha256sum ../requirements.txt > "$3" diff --git a/bin/wrd.do b/bin/wrd.do @@ -1,7 +0,0 @@ -exec >&2 -redo-ifchange ../wrd/go.mod $(find ../wrd -name '*.go') -case "$3" in -/*) out=$3 ;; -*) out=$PWD/$3 ;; -esac -(cd ../wrd && go build -o "$out" .) diff --git a/justfile b/justfile @@ -1,4 +1,4 @@ -redo := "redo" +knit := "knit" cargo := "cargo" deploy_dir := home_directory() / ".local/bin" @@ -12,15 +12,15 @@ default: # Build every tool all: - {{ redo }} all + {{ knit }} all # Build one or more tools, e.g. just build lazymaster build +targets: - {{ redo }} {{ "bin/" + replace(targets, " ", " bin/") }} + {{ knit }} {{ "bin/" + replace(targets, " ", " bin/") }} # Build and run a tool run target *args: - @{{ redo }} bin/{{ target }} && ./bin/{{ target }} {{ args }} + @{{ knit }} bin/{{ target }} && ./bin/{{ target }} {{ args }} # Build and copy tools to ~/.local/bin deploy +targets: @@ -28,7 +28,7 @@ deploy +targets: @for target in {{ targets }}; do \ case "$target" in mpd) bins="{{ mpd_bins }}" ;; *) bins="$target" ;; esac; \ for bin in $bins; do \ - {{ redo }} bin/"$bin" && \ + {{ knit }} bin/"$bin" && \ install -m 755 bin/"$bin" {{ deploy_dir }}/ && \ echo "deployed $bin to {{ deploy_dir }}"; \ done; \ @@ -50,7 +50,7 @@ rustfmt: # Update `requirements.txt` lockfile from requirements.in pip-update: - {{ redo }} bin/venv-stamp + {{ knit }} .venv-stamp .venv/bin/pip install --quiet pip-tools .venv/bin/pip-compile --generate-hashes --strip-extras requirements.in -o requirements.txt @@ -62,5 +62,5 @@ cargo-lockfile: clean: {{ cargo }} clean for dir in pmn pracomer speediness; do rm -rf "$dir"/zig-out "$dir"/.zig-cache; done - find bin -type f ! -name '*.do' -delete - rm -rf .venv .redo + find bin -type f -delete + rm -rf .venv .knit .venv-stamp diff --git a/knitfile b/knitfile @@ -0,0 +1,94 @@ +knit = require("knit") + +root = knit.abs(".") + +cflags := -Wall -Wextra -O2 -march=native -mtune=native -fanalyzer -Wshadow -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE -Wformat -Werror=format-security -Wnull-dereference -Wdangling-pointer -Wtrampolines -Walloca -Wcast-align=strict -Wdate-time -Wfloat-equal -Wpointer-arith -Wredundant-decls -Wswitch-default -Wvla -Wwrite-strings +ldflags := -lmpdclient -Wl,-z,relro -Wl,-z,now +cc := /usr/bin/cc + +hue_rb := hue/lib/hue.rb hue/lib/hue/bridge.rb hue/lib/hue/bulb.rb hue/lib/hue/cli.rb hue/lib/hue/colors.rb hue/lib/hue/animations/candle.rb hue/lib/hue/animations/sunrise.rb hue/lib/hue/cli/command.rb hue/lib/hue/colors/color.rb hue/lib/hue/colors/color_temperature.rb hue/lib/hue/colors/hue_saturation.rb hue/lib/hue/colors/rgb.rb hue/lib/hue/colors/xy.rb hue/lib/hue/config/abstract.rb hue/lib/hue/config/application.rb hue/lib/hue/config/bridge.rb hue/lib/hue/extensions/bridge.rb hue/lib/hue/extensions/bulb.rb hue/lib/hue/extensions/hue.rb hue/lib/hue/utilities/indentation.rb hue/lib/hue/cli/commands/delete.rb hue/lib/hue/cli/commands/light.rb hue/lib/hue/cli/commands/lights.rb hue/lib/hue/cli/commands/register.rb hue/lib/hue/cli/processors/light_state_alias.rb + +return b{ +$ bin/dam: Cargo.toml Cargo.lock rust-toolchain.toml dam/Cargo.toml $(knit.glob("dam/src/*.rs")) + cargo build --release -p dam + cp target/release/dam $output + +$ bin/lastfm_rs: Cargo.toml Cargo.lock rust-toolchain.toml lastfm_rs/Cargo.toml $(knit.glob("lastfm_rs/src/*.rs")) + cargo build --release -p lastfm_rs + cp target/release/lastfm_rs $output + +$ bin/plants: Cargo.toml Cargo.lock rust-toolchain.toml plants/Cargo.toml $(knit.glob("plants/src/*.rs")) + cargo build --release -p plants + cp target/release/plants $output + +$ bin/pmn: pmn/build.zig pmn/build.zig.zon $(knit.glob("pmn/src/*.zig")) + cd pmn && zig build -Doptimize=ReleaseSafe + cp pmn/zig-out/bin/pmn $output + +$ bin/pracomer: pracomer/build.zig pracomer/build.zig.zon $(knit.glob("pracomer/src/*.zig")) + cd pracomer && zig build -Doptimize=ReleaseSafe + cp pracomer/zig-out/bin/pracomer $output + +$ bin/speediness: speediness/build.zig speediness/build.zig.zon $(knit.glob("speediness/src/*.zig")) + cd speediness && zig build -Doptimize=ReleaseSafe + cp speediness/zig-out/bin/speediness $output + +$ bin/wrd: wrd/go.mod $(knit.glob("wrd/*.go")) + cd wrd && go build -o $(root)/$output . + +$ bin/mpd_add_to_playlist: mpd/mpd_add_to_playlist.c + $cc $cflags -o $output $input $ldflags + +$ bin/mpd_add_to_queue: mpd/mpd_add_to_queue.c + $cc $cflags -o $output $input $ldflags + +$ bin/mpd_edit_queue: mpd/mpd_edit_queue.c + $cc $cflags -o $output $input $ldflags + +$ bin/mpd_update_library: mpd/mpd_update_library.c + $cc $cflags -o $output $input $ldflags + +$ bin/mpd_update_queue: mpd/mpd_update_queue.c + $cc $cflags -o $output $input $ldflags + +$ .venv-stamp: requirements.txt + python3 -m venv .venv + .venv/bin/pip install --quiet --require-hashes -r requirements.txt + sha256sum requirements.txt > $output + +$ bin/diggah: .venv-stamp diggah/diggah.py + printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/diggah/diggah.py" "$$@"\n' $root $root > $output + chmod +x $output + +$ bin/kundali: .venv-stamp kundali/kundali.py + printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/kundali/kundali.py" "$$@"\n' $root $root > $output + chmod +x $output + +$ bin/lazymaster: .venv-stamp lazymaster/lazymaster.py + printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/lazymaster/lazymaster.py" "$$@"\n' $root $root > $output + chmod +x $output + +$ bin/nts: .venv-stamp nts/nts.py + printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/nts/nts.py" "$$@"\n' $root $root > $output + chmod +x $output + +$ bin/shuffle: .venv-stamp shuffle/shuffle.py + printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/shuffle/shuffle.py" "$$@"\n' $root $root > $output + chmod +x $output + +$ bin/hue: hue/bin/hue $hue_rb + printf '#!/bin/sh\nexec ruby -I"%s/hue/lib" "%s/hue/bin/hue" "$$@"\n' $root $root > $output + chmod +x $output + +$ bin/reflink-snap: reflink-snap/reflink-snap.rb + printf '#!/bin/sh\nexec ruby "%s/reflink-snap/reflink-snap.rb" "$$@"\n' $root > $output + chmod +x $output + +$ all:VB: bin/dam bin/lastfm_rs bin/plants \ + bin/pmn bin/pracomer bin/speediness \ + bin/wrd \ + bin/mpd_add_to_playlist bin/mpd_add_to_queue bin/mpd_edit_queue \ + bin/mpd_update_library bin/mpd_update_queue \ + bin/diggah bin/lazymaster bin/nts bin/shuffle bin/kundali \ + bin/hue bin/reflink-snap +}