Skip to content

Instantly share code, notes, and snippets.

@bikallem
Created December 27, 2019 15:14
Show Gist options
  • Select an option

  • Save bikallem/906ca4cb3b2749b7ca0a7acb0a580681 to your computer and use it in GitHub Desktop.

Select an option

Save bikallem/906ca4cb3b2749b7ca0a7acb0a580681 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
# Converts .ml to .re
ls -A *ml* | while read file; do
if [[ "$file" =~ (\.ml|\.mli)$ ]]; then
# Convert from OCaml to ReasonML
newfile=$(echo $file | sed 's/\.ml/\.re/' | python -c "print raw_input().capitalize()")
echo "Converting $file to $newfile"
esy refmt --parse=ml -p re $file >$newfile
git add "$newfile"
else
[[ "$VERBOSE" = "" ]] || echo "Leaving $file as is"
fi
done
# Converts file name to Reason convention
ls -A *re* | while read file; do
newfile=$(echo $file | sed -r 's/_([a-z])/\U\1/gi')
if [[ "$file" != "$newfile" ]]; then
echo "moving $file to $newfile"
git mv "$file" "$newfile"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment