bolt icon indicating copy to clipboard operation
bolt copied to clipboard

Programmatic filtering

Open jamiekyle-eb opened this issue 6 years ago • 3 comments

Idea:

bolt ws --when [ -f ./tsconfig.json ] -- tsc

jamiekyle-eb avatar Jan 28 '19 20:01 jamiekyle-eb

Would we attempt to parse the test block there, or allow it to run in the shell? Any idea how we could read the return code of that with passing it in as a string 🤔?

lukebatchelor avatar Jan 28 '19 21:01 lukebatchelor

I've written a shell script to solve my need here:

index=0
split=-1

for arg in "$@"
do
  if [ "$arg" = '--' ]; then
    split=$index
    break
  fi
  index=$(expr $index + 1)
done

if [ $split -eq -1 ]; then
  echo "Invalid usage, expected: run-if condition -- command"
  exit 1
fi

cond=${@:0:$(expr $split + 1)}
cmd=${@:$(expr $split + 2)}

if eval $cond; then
  exec $cmd
fi

Which you can then run as:

bolt ws exec -- run-if [ -f tsconfig.json ] -- tsc

Maybe bolt could have something like this built in

jamiekyle-eb avatar Jan 28 '19 21:01 jamiekyle-eb

Never mind, the above script shits itself in different places

jamiekyle-eb avatar Jan 29 '19 00:01 jamiekyle-eb