All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.home.bash.complete Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
__stageList() {
  local base=${{stool.home}}/backstages
  # don't use ls, it's an alias on many systems:
  local lscmd=/bin/ls
  for dir in $($lscmd -1 $base); do
    ls=$($lscmd -ld "$base/$dir")
    dir=$(expr "$ls" : '.*-> \(.*\)$')
    dir=$(dirname $dir)
    echo $(__stageName $dir)
  done
  echo none
}
_stool_complete() {
      local cur prev cmd
      local select_opts general_opts
      COMPREPLY=()
      cur="${COMP_WORDS[COMP_CWORD]}"
      prev="${COMP_WORDS[COMP_CWORD-1]}"
      cmd="stop remove build setup validate version help system-start config import system-stop refresh move restart status select list create history start cd"
      general_opts="-v -e"
      select_opts="-stage -all"
      fail_opts="before after never"

      case "${prev}" in
        create)
            if [[ ${cur} == -* ]] ; then
                local option="-quiet -prefix -name "
                COMPREPLY=( $(compgen -W "${option}" -- ${cur}) )
                return 0
            fi
            # url
            return 0
            ;;
        import)
            if [[ ${cur} == -* ]] ; then
                local option="-max"
                COMPREPLY=( $(compgen -W "${option}" -- ${cur}) )
                return 0
            else
                COMPREPLY=( $(compgen -f "$2" ) )
                return 0
            fi
            ;;
        select)
            local stages=$(__stageList)
            COMPREPLY=( $(compgen -W "${stages}" -- ${cur}) )
            return 0
            ;;
        status)
            local stages=$(__stageList)
            COMPREPLY=( $(compgen -W "${stages}" -- ${cur}) )
            return 0
            ;;
        stop)
            if [[ ${cur} == -* ]] ; then
                local option="-sleep -stail"
                COMPREPLY=( $(compgen -W "${option}" -- ${cur}) )
            fi
            ;;
        config)
            compopt +o nospace &>/dev/null
            local option="suffix expire maven.opts java.home tomcat.select tomcat.perm tomcat.heap tomcat.version tomcat.opts port.prefix build cookies pustefix.mode autoRefresh comment fitnesse logstash"
            COMPREPLY=( $(compgen -o nospace -W "${option}" -- ${cur}) )
            return 0
            ;;
        restart)
            if [[ ${cur} == -* ]] ; then
                local option="-debug"
                COMPREPLY=( $(compgen -W "${option}" -- ${cur}) )
            fi
            ;;
        remove)
            if [[ ${cur} == -* ]] ; then
                local option="-force -batch"
                COMPREPLY=( $(compgen -W "${option}" -- ${cur}) )
                return 0
            fi
            ;;
           cd)
            local lst="backstage conf java jmx run tomcat conf logs temp work  "
            COMPREPLY=( $(compgen -W "${lst}" -- ${cur}) )
            return 0
            ;;
        *)
            ;;
      esac

      COMPREPLY=( $(compgen -W "${cmd}" -- ${cur}) )
      return 0
}

complete -F _stool_complete stool




© 2015 - 2024 Weber Informatics LLC | Privacy Policy