summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-06-06 11:33:08 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-09-07 15:36:40 +0200
commitf68ad54e89fb5f210982f87f958a6b10195f07da (patch)
tree0b038c941369cf1647812f8fa8627f947a1c7c37
parentce2aaf51b3fa94cd270cf779d76428307e16e649 (diff)
Add nix-script channel command, which is a caller itself
-rwxr-xr-xnix-script-channel.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/nix-script-channel.sh b/nix-script-channel.sh
new file mode 100755
index 0000000..6a24eca
--- /dev/null
+++ b/nix-script-channel.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+
+# Level-2 wrapper to be able to
+#
+# nix-script channel <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 "channel")
+EOS
+}
+
+while getopts "hl" OPTION
+do
+ case $OPTION in
+ h)
+ usage
+ exit 0
+ ;;
+
+ l)
+ caller_util_list_subcommands_for "nix-script-channel"
+ exit 0
+ ;;
+ *)
+ ;;
+ esac
+done
+
+if [[ -z "$1" ]]
+then
+ # no command available
+ stderr "No command given"
+ usage
+ exit 1
+fi
+
+SCRIPT=$(caller_util_get_script "nix-script-channel" "$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