summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-09-07 17:41:21 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-09-07 18:49:03 +0200
commitca9a3fc143e5085bba50cf7721d80a8109223e0a (patch)
treebe6ab686844a5144b5a4d69708374116772216b8
parent4dcf630cbc02cc1ce408ec9206c41bb8ee7a4d56 (diff)
Add level 2 caller: "container" subcommand
-rwxr-xr-xnix-script-container.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/nix-script-container.sh b/nix-script-container.sh
new file mode 100755
index 0000000..14e6241
--- /dev/null
+++ b/nix-script-container.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+
+# Level-2 wrapper to be able to
+#
+# nix-script container <command>
+
+source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh
+
+export VERBOSE
+
+usage() {
+ cat <<EOS >&2
+ $(help_synopsis "${BASH_SOURCE[0]}" "[-h] [-l] <command>")
+
+ -l List all available commands
+ -h Show this help and exit
+
+$(help_end "container")
+EOS
+}
+
+while getopts "hl" OPTION
+do
+ case $OPTION in
+ h)
+ usage
+ exit 0
+ ;;
+
+ l)
+ caller_util_list_subcommands_for "nix-script-container"
+ exit 0
+ ;;
+ *)
+ ;;
+ esac
+done
+
+[[ -z "$1" ]] && stderr "No command given" && usage && exit 1
+
+SCRIPT=$(caller_util_get_script "nix-script-container" "$1")
+[[ -z "$SCRIPT" ]] && exit 1
+stdout "SCRIPT = $SCRIPT"
+
+stdout "Parsing args for '$1'"
+SCRIPT_ARGS=$(echo $* | sed -r "s/(.*)$1(.*)/\2/")
+
+stdout "Calling: '$SCRIPT $SCRIPT_ARGS'"
+RC_CONFIG=$RC_CONFIG RC_NIXPKGS=$RC_NIXPKGS exec bash $SCRIPT $SCRIPT_ARGS
+