Last active
May 27, 2023 04:01
-
-
Save sleexyz/4efa3da428b1e6c4856071b69385c97d to your computer and use it in GitHub Desktop.
helpers to recurse into subdirectories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list: | |
#!/usr/bin/env just _recurse bash | |
echo "$DIR": | |
just -l | tail -n +2 | |
test: (_recurse_subcommand "test") | |
_recurse_subcommand command: | |
#!/usr/bin/env just _recurse bash | |
if [[ "$DIR" == "." ]]; then | |
exit 0 | |
fi | |
if ! just -l | grep -q '{{command}}$'; then | |
exit 0 | |
fi | |
echo "$DIR": | |
just {{command}} |& pr -to 4 # add indent | |
_recurse shell script_file: | |
#!/bin/bash | |
file_paths() { | |
ag -l -G 'Justfile$' . | sort | |
} | |
while IFS= read -r file_path; do | |
export DIR=$(dirname $file_path) | |
(cd $DIR && {{shell}} {{script_file}}) | |
done <<< "$(file_paths)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment