aboutsummaryrefslogtreecommitdiff
path: root/contrib/kiss-new
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-04-20 18:11:43 +0000
committermerakor <cem@ckyln.com>2020-04-20 18:11:43 +0000
commit7a4fcf554c75c5f73bf51f840e72ba7fbedb7e60 (patch)
tree4e0c47c6a2d14295a7f48553793d11008fed24cc /contrib/kiss-new
parent395d0f1a6019c176de72ce3aa30f57eb810b0d9b (diff)
downloadcpt-7a4fcf554c75c5f73bf51f840e72ba7fbedb7e60.tar.gz
contrib: additions, usage, simplifications
FossilOrigin-Name: 8d7d95914b0d1d981416c4fe1511987af3dd0170d436ee2176de9cb279988dd0
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'"