This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/bin/pipeline
2020-02-13 11:14:03 -06:00

40 lines
1,004 B
Bash
Executable file

#!/usr/bin/env sh
SAVED_PIPELINE_DIR="$DOTFILES_PATH/bin/pipelines"
mkdir -p "$SAVED_PIPELINE_DIR"
if [ -n "${1+x}" ]; then
pdir="$SAVED_PIPELINE_DIR/$1"; shift
mkdir -p "$pdir"
if [ -z ${1+x} ]; then
td="$(mktemp -p "$pdir" -d "tmp_pipeline.XXXXXXXX")"
trap "rm -rf '$td'" EXIT
else
td="$pdir/$1"; shift
mkdir -p "$td"
fi
transform="$pdir/transform"
else
td="$(mktemp --tmpdir -d pipeline.XXXXXXXX)"
transform="$td/transform"
trap "rm -rf '$td'" EXIT
fi
[ ! -e "$transform" ] && \
printf "#!/usr/bin/env bash\n# you must save this buffer manually\n# for %s\n
base64" "${td}" > "$transform"
in="$td/in"; [ -n "${1+x}" ] && in="${1}" && shift
out="$td/out"; [ -n "${1+x}" ] && out="${1}" && shift
# TODO: if no logging, log="/dev/null"
log="$td/log"
touch "$log"
chmod +x "$transform"
# TODO: saved inputs?
echo "Hello World" > "$in"
env PIPELINE_IN="$id" PIPELINE_TRANSFORM="$transform" PIPELINE_OUT="$out" nvim --cmd "source $DOTFILES_PATH/apps/neovim/scripts/pipeline.vim"