Add 'cargo flow' tool

f1173f231a57e2640512c55a02486cee7bb6d898
Alexis Sellier committed ago 1 parent b6fd5c57
bin/cargo-flow added +7 -0
1 +
#!/bin/sh
2 +
3 +
# Remove the "flow" argument.
4 +
shift
5 +
6 +
# Exec cargo-watch with `flow-once`
7 +
exec cargo watch -qc -i target/* -i errors.err -x 'flow-check' -w "${@:-$PWD}"
bin/cargo-flow-check added +22 -0
1 +
#!/bin/sh
2 +
3 +
tmpfile=$(mktemp /tmp/cargo-flow.XXXXXX)
4 +
result="$(cargo check --color always --all 2>&1 1>/dev/null)"
5 +
6 +
if [ "$?" -ne 0 ]; then
7 +
	# Display the results, but also output them to `errors.err`, which vim
8 +
	# can read.
9 +
	echo "$result" | tee errors.err
10 +
11 +
	# We have to do this dance with the tempfile, because `sed`
12 +
	# isn't able to do the edits in memory (for some reason),
13 +
	# and creates a temporary file in $PWD which triggers `cargo watch`.
14 +
	#
15 +
	#          (╯°□°)╯︵ ┻━┻
16 +
	#
17 +
	sed -r 's/\x1b\[[0-9;]*m?//g' errors.err > $tmpfile
18 +
	mv -f $tmpfile errors.err
19 +
else
20 +
	echo "$result"
21 +
	echo -n > errors.err
22 +
fi