Skip to content

Commit

Permalink
Add level 2 caller: "container" subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasbeyer committed Sep 7, 2015
1 parent 4dcf630 commit ca9a3fc
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions nix-script-container.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ca9a3fc

Please sign in to comment.