btr-hook and some generalizations
[m6w6/btr] / share / btr / btrc.sh
old mode 100644 (file)
new mode 100755 (executable)
index beff3b4..8a38bb3
@@ -1,34 +1,7 @@
 #!/bin/bash
 
-function btrc-help {
-       btr-banner
-       echo
-       echo "Usage: $(basename $0) [-hyvq] [<options>] [action] <build>"
-       echo
-       echo "    -h, --help                Display this help"
-       echo "    -y, --yes                 Always assume yes"
-       echo "    -v, --verbose             Be more verbose"
-       echo "    -q, --quiet               Be more quiet"
-       echo
-       echo "  Options:"
-       echo "    -D, --directory=<directory>"
-       echo "                              Use this directory as work root"
-       echo
-       echo "  Actions:"
-       echo "    s[tatus]                  Show the status of the build"
-       echo "    r[un]                     Make a BTR run"
-       echo "    c[ancel]                  Cancel any currently running BTR job"
-       echo "    t[erminate]               Terminate the BTR daemon"
-       echo
-       echo "  Arguments:"
-       echo "    <build>                   The build id of the \`btrd\` daemon, usually"
-       echo "                              something like \$repository@\$branch[-\$suffix]."
-       echo
-       exit
-}
-export -f btrc-help
-
 function btrc-parseargs {
+       eval set -- "$BTR_EXTRA_ARGS"
        while test $# -gt 0
        do
                case "$1" in
@@ -57,57 +30,13 @@ function btrc-parseargs {
        done
 }
 
-function btrc-parseopts {
-       local shortoptions="hvqyD:"
-       local longoptions="help,verbose,quiet,yes,directory:"
-       local options=$(getopt \
-               --options "$shortoptions" \
-               --longoptions "$longoptions" \
-               -- "$@" \
-       )
-
-       if test $? -ne 0 ; then
-               btrc-help
-       fi
-       
-       eval set -- "$options"
-       
-       while test $# -gt 1
-       do
-               case "$1" in
-               -h|--help)
-                       btrc-help
-                       ;;
-               -y|--yes)
-                       BTR_FORCEYES=true
-                       ;;
-               -v|--verbose)
-                       BTR_VERBOSE=true
-                       BTR_QUIET=false
-                       ;;
-               -q|--quiet)
-                       BTR_QUIET=true
-                       BTR_VERBOSE=false
-                       ;;
-               #
-               -D|--directory)
-                       BTR_RUNDIR="$2"
-                       shift
-                       ;;
-               #
-               --)
-                       shift
-                       btrc-parseargs "$@"
-               esac
-               shift
-       done
-}
-export -f btrc-parseopts
-
 function btrc-setup {
+       btrc-parseargs
+       
        if test -z "$BTR_BUILD"
        then
-               btrc-help
+               btr-banner
+               btr-help
        fi
        
        if test -z "$BTR_ACTION"
@@ -116,7 +45,7 @@ function btrc-setup {
        fi
        
        btr-setup-rundir
-       btr-setup-verbosity
+       btr-setup-verbosity false
        
        BTR_PIDFILE="$BTR_RUNDIR/$BTR_BUILD.pid"
        BTR_LOGFILE="$BTR_RUNDIR/$BTR_BUILD.log"
@@ -131,7 +60,7 @@ function btrc-setup {
                        cat "$BTR_LOGFILE"
                        echo
                fi
-               error "Could not find pid file of btr daemon for '$BTR_BUILD' in $BTR_RUNDIR."
+               error "Could not find btrd pid file of '$BTR_BUILD' in $BTR_RUNDIR."
        fi
 }
 export -f btrc-setup