Files
yait/bin/yait
2026-01-12 16:41:17 -05:00

82 lines
2.0 KiB
Bash
Executable File

#! /bin/sh
# Highly opinionated C and SH project generator
scriptversion="1"
#
#
# Copyright (C) 2025-2026 vx-clutch
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
strip_comments() {
for file in "$@"; do
if [ ! -f "$file" ]; then
echo "Error: File '$file' does not exist." >&2
return 1
fi
sed 's/^[[:space:]]*;.*//; /^[[:space:]]*$/d' "$file"
done
}
me=$0
version="$me v$scriptversion
Copyright (C) 2025-2026 fSD.
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."
usage="\
Usage: $me [OPTION]... <version> <dir>
Highly opinionated C and SH project generator
Options:
--help print this help and exit
--version output version information
-x <language> set project type
-S small project creation
-f overwrite existing files
-n <name> set project name
-a <author> set project author
-r initialize Git repository for the project
-q surpress output"
x="C"
S=
f=
n=
a=$(git config user.name)
r=
q=
mfmt() {
if [ -z "$q" ]; then
echo "$me: $*"
fi
}
while [ $# -gt 0 ]; do
case $1 in
--help) echo "$usage"; exit 0 ;;
--version) echo "$version"; exit 0 ;;
-x) shift; x=$1; break ;;
-S) S=true; break ;;
-f) f=true; break ;;
-n) shift; n=$1; break ;;
-a) shift; a=$1; break ;;
-r) r=true; break ;;
-q) q=true; break ;;
-*) echo "$me: Unknown option '$1'." >&2; exit 1 ;;
*) break ;;
esac
done
if ! [ $# -gt 0 ]; then
echo "$usage"
exit 0
fi