Last active
July 20, 2020 08:20
-
-
Save thesephist/8565bbde8ea7b8c778dbe9054b3c16d5 to your computer and use it in GitHub Desktop.
Thin CLI wrapper around inkfmt utility to format files on disk
This file contains hidden or 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
#!/bin/sh | |
# | |
# This is a thin wrapper around https://github.com/thesephist/ink | |
# to give me two CLI commands when this script is placed | |
# in /usr/local/bin. | |
# | |
# 1. I can type `inkfmt file.ink` to see any formatting changes | |
# needed in file.ink. | |
# 2. I can type `inkfmt fix file.ink` to make the script fix | |
# all formatting errors in file.ink in-place of the file. | |
INKFMT=/home/thesephist/src/inkfmt/fmt.ink | |
if [[ $1 == "fix" ]]; then | |
for file in "${@:2}" | |
do | |
echo 'inkfmt fix: '$file | |
$INKFMT < $file > /tmp/_inkfmt_fix.ink | |
cp /tmp/_inkfmt_fix.ink $file | |
done | |
else | |
for file in "$@" | |
do | |
echo 'inkfmt changes in '$file':' | |
$INKFMT < $file | diff $file - --color | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment