commit 4a0c8dd0c67314a4949adaff478e118aeb27c2c3
parent 3c36fc3963a39c58c9a2c21f1e746ced645993dd
Author: vx-clutch <[email protected]>
Date: Mon, 12 Jan 2026 18:29:29 -0500
correct copyright and add small shell
Diffstat:
| M | bin/yait | | | 128 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- |
1 file changed, 108 insertions(+), 20 deletions(-)
diff --git a/bin/yait b/bin/yait
@@ -5,15 +5,15 @@ scriptversion="1"
#
#
-# Copyright (C) 2025-2026 vx-clutch
+# Copyright (C) 2025-2026 fSD
# 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.
-me=$0
-version="$me v$scriptversion
+me=$(basename "$0")
+version="$me\/fSD v$scriptversion
Copyright (C) 2025-2026 fSD.
This is free software; you are free to change and redistribute it.
@@ -27,35 +27,122 @@ Options:
--help print this help and exit
--version output version information
- -x <language> set project type
- -S small project creation
- -f overwrite existing files
- -a <author> set project author
- -r initialize Git repository for the project
- -q surpress output"
+ -x <language> set project type
+ -d <description> set a description
+ -S small project creation
+ -f overwrite existing files
+ -a <author> set project author
+ -r initialize Git repository for the project
+ -q surpress output"
-x=C # language
+x=c # language
+d="Does a thing" # package description
S= # small project creation (bool)
f= # force (bool)
a=$(git config user.name) # author
r= # initialize repository (bool)
q= # surpress output
-format() {
+say() {
if [ -z "$q" ]; then
echo "$me: $*"
fi
}
+lsay() {
+ if [ -z "$q" ]; then
+ echo " => $*"
+ fi
+}
+
create_project() {
name=$1
if ! echo "$name" | grep -qE '^[A-Za-z0-9_-]+$'; then
- format "invalid name '$name'"
+ say "invalid name '$name'"
exit 1
fi
- echo "invoke"
+ shell() {
+ if [ -z "$S" ]; then
+ mkdir "$name" || return
+ cd "$name" || return
+
+ touch COPYING Makefile README.md "$name.1" .gitignore
+ mkdir bin
+ else
+ cat <<EOF > "$name"
+#! /bin/sh
+# $d
+
+scriptversion="1"
+
+#
+#
+# Copyright (C) $(date "+%Y") $a
+# 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.
+
+me=\$0
+version="\$me/$a v\$scriptversion
+
+Copyright (C) $(date "+%Y") $a.
+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]... <arg1> <arg2>
+$d
+
+Options:
+ --help print this help and exit
+ --version output version information"
+
+say() {
+ if [ -z "\$q" ]; then
+ echo "\$me: \$*"
+ fi
+}
+
+lsay() {
+ if [ -z "\$q" ]; then
+ echo " => \$*"
+ fi
+}
+
+if ! [ \$# -gt 0 ]; then
+ echo "\$usage"
+ exit 0
+fi
+
+while [ \$# -gt 0 ]; do
+ case \$1 in
+ --help) echo "\$usage"; exit 0 ;;
+ --version) echo "\$version"; exit 0 ;;
+ -*) echo "\$me: Unknown option '\$1'." >&2; exit 1 ;;
+ esac
+done
+
+say hello world
+EOF
+ chmod +x "$name"
+ fi
+ }
+
+ c() {
+ lsay "sub routine: c"
+ }
+
+ case $x in
+ sh) say "using shell"; shell ;;
+ c) say "using C"; c ;;
+ *) say "defaulting to C"; c ;;
+ esac
+
+ say "made $name at $(realpath "$name")"
}
if ! [ $# -gt 0 ]; then
@@ -67,13 +154,14 @@ 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 ;;
- -a) shift; a=$1; break ;;
- -r) r=true; break ;;
- -q) q=true; break ;;
+ -x) shift; x="$1"; shift ;;
+ -d) shift; d="$1"; shift ;;
+ -S) S=true; shift ;;
+ -f) f=true; shift ;;
+ -a) shift; a="$1"; shift ;;
+ -r) r=true; shift ;;
+ -q) q=true; shift ;;
-*) echo "$me: Unknown option '$1'." >&2; exit 1 ;;
- *) create_project $1; shift ;;
+ *) create_project "$1"; shift ;;
esac
done