feat: --version, fix: --post fixes
All checks were successful
Lint / shellcheck (push) Successful in 19s

This commit is contained in:
2026-03-18 22:18:13 +01:00
parent 9ccba8fd4e
commit 9f5d1089a2
2 changed files with 25 additions and 3 deletions

20
kewt.sh
View File

@@ -13,6 +13,7 @@ Usage: $invoked_as [--from <src>] [--to <out>]
$invoked_as --new [title] $invoked_as --new [title]
$invoked_as --update [dir] $invoked_as --update [dir]
$invoked_as --post $invoked_as --post
$invoked_as --version
$invoked_as --help $invoked_as --help
Options: Options:
@@ -20,6 +21,7 @@ Options:
--new [title] Create a new site directory (default: site) --new [title] Create a new site directory (default: site)
--update [dir] Update site.conf and template.html with latest defaults (defaults to current directory) --update [dir] Update site.conf and template.html with latest defaults (defaults to current directory)
--post Create a new empty post file in the configured posts_dir with current date and time as name --post Create a new empty post file in the configured posts_dir with current date and time as name
--version Show version information.
--from <src> Source directory (default: site) --from <src> Source directory (default: site)
--to <out> Output directory (default: out) --to <out> Output directory (default: out)
EOF EOF
@@ -259,6 +261,10 @@ while [ $# -gt 0 ]; do
shift shift
fi fi
;; ;;
--version|-v)
echo "kewt version git"
exit 0
;;
--post) --post)
post_mode="true" post_mode="true"
;; ;;
@@ -301,7 +307,13 @@ done
ensure_root_defaults ensure_root_defaults
[ -z "$src" ] && src="site" if [ -z "$src" ]; then
if [ "$post_mode" = "true" ] && [ -f "./site.conf" ]; then
src="."
else
src="site"
fi
fi
[ -z "$out" ] && out="out" [ -z "$out" ] && out="out"
src="${src%/}" src="${src%/}"
@@ -713,7 +725,11 @@ eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type d -print" | sort | while
[ "$dir_indexes" != "true" ] && continue [ "$dir_indexes" != "true" ] && continue
if [ ! -f "$dir/index.md" ]; then if [ ! -f "$dir/index.md" ]; then
if [ "$single_file_index" = "true" ]; then is_posts_dir="false"
if [ -n "$posts_dir" ] && { [ "$rel_dir" = "$posts_dir" ] || [ "./$rel_dir" = "$posts_dir" ]; }; then
is_posts_dir="true"
fi
if [ "$single_file_index" = "true" ] && [ "$is_posts_dir" = "false" ]; then
md_count=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md" | wc -l) md_count=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md" | wc -l)
if [ "$md_count" -eq 1 ]; then if [ "$md_count" -eq 1 ]; then
md_file=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md") md_file=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md")

View File

@@ -26,7 +26,13 @@ exit $?
#==PAYLOAD== #==PAYLOAD==
EOF EOF
tar -cz -C "$REPO_ROOT" kewt.sh markdown.sh awk styles >> "$OUT_FILE" VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "standalone")
tmpbuild=$(mktemp -d)
cp -r "$REPO_ROOT/kewt.sh" "$REPO_ROOT/markdown.sh" "$REPO_ROOT/awk" "$REPO_ROOT/styles" "$tmpbuild/"
sed -e "s/kewt version git/kewt version $VERSION/" "$tmpbuild/kewt.sh" > "$tmpbuild/kewt.sh.tmp" && mv "$tmpbuild/kewt.sh.tmp" "$tmpbuild/kewt.sh"
chmod +x "$tmpbuild/kewt.sh" "$tmpbuild/markdown.sh"
tar -cz -C "$tmpbuild" kewt.sh markdown.sh awk styles >> "$OUT_FILE"
rm -rf "$tmpbuild"
chmod +x "$OUT_FILE" chmod +x "$OUT_FILE"