aboutsummaryrefslogtreecommitdiff
path: root/contrib/kiss-new
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/kiss-new')
-rwxr-xr-xcontrib/kiss-new53
1 files changed, 17 insertions, 36 deletions
diff --git a/contrib/kiss-new b/contrib/kiss-new
index c5ded48..d50cc5b 100755
--- a/contrib/kiss-new
+++ b/contrib/kiss-new
@@ -1,45 +1,26 @@
-#!/bin/sh
+#!/bin/sh -e
-die() {
- printf 'error: %s.\n' "$*" >&2
- exit 1
-}
+out() { printf '\033[1;33m-> \033[m%s\n' "$@" >&2 ;}
+die() { printf '\033[1;31m!> \033[m%s\n' "$@" >&2 ; exit 1 ;}
-log() {
- printf '=> %s.\n' "$*"
+[ "$1" ] || {
+ out "usage: ${0##*/} <name> [version] [source]" \
+ "Create boilerplate kiss packages"
+ exit 0
}
-main() {
- [ "$1" ] || {
- log Create boilerplate KISS packages
- log Usage: kiss-new name version source
-
- exit
- }
-
- [ -d "$1" ] &&
- die Package "$1" already exists.
+[ -d "$1" ] && die "Package '$1' already exists."
- mkdir -p "$1" ||
- die Couldn\'t create directory in "$PWD"
+# Create the directory
+mkdir -p "$1"
- cd "$1" ||
- die Couldn\'t enter directory "$1/"
+# Create the build file
+printf '%s\n' "#!/bin/sh -e" > "$1/build" ; chmod +x "$1/build"
- log Creating build file; {
- printf '#!/bin/sh -e\n' > build
- chmod +x build
- }
+# Create the version file
+printf '%s\n' "$2 1" > "$1/version"
- log Creating version file with "'${2%% *} 1'"; {
- printf '%s\n' "${2%% *} 1" > version
- }
-
- log Creating sources file with "'$3'"; {
- printf '%s\n' "$3" > sources
- }
-
- log Package "$1" created in "$PWD"
-}
+# Create the sources file
+printf '%s\n' "$3" > "$1/sources"
-main "$@"
+out "Package '$1' created to '$PWD/$1'"