BrettMayson / HEMTT

Build System for Arma 3
https://brettmayson.github.io/HEMTT
GNU General Public License v2.0
109 stars 40 forks source link

init auto-detection #6

Closed BrettMayson closed 1 year ago

BrettMayson commented 5 years ago

./hemtt init should try to auto-detect the name, prefix, and author of the project by looking in common places.

Potentially even make them optional if the values can be found.

bovine3dom commented 5 years ago

Related to this - I'd like to make hemtt.json totally optional for e.g, hemtt sign in #41, which would pave the way for hemtt unpack etc.

Here's a non-portable way of getting an authors array which might help thinking about it in Rust:

echo "[";
# Get all authors arrays
grep -F "authors[] =" **config.cpp |\
# Extract the authors providing that they aren't foreign (fix later)
grep -o '\{.*\}' | grep -Eo '[A-Za-z0-9]+[ A-Za-z0-9]*' |\
# Sort them by the number of times they appear
sort | uniq -c | sort -r | tr -s ' ' | cut -d' ' -f3- |\
# Stick commas around them
sed 's|^\(.*\)$|"\1",|g';
echo "]"