view distribution/packaging/shared/bash-completion/thermostat-completion @ 2593:767b2627c92d

Implement cli/shell command-group support Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-November/021748.html Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-December/021824.html Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-January/021934.html Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-February/022139.html
author Andrew Azores <aazores@redhat.com>
date Tue, 14 Feb 2017 11:26:33 -0500
parents 3e1ccd4a2d51
children
line wrap: on
line source

#/bin/bash
_thermostat() 
{
    local cur prev opts base
    local thermostat_install_dir thermostat_logging_opts
    thermostat_install_dir="${thermostat.home}"
    thermostat_logging_opts="-J-Djava.util.logging.config.file=\"${thermostat_install_dir}/etc/bash-complete-logging.properties\""
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    # Thermostat Options
    # All valid commands and options are prefixed with a single space
    opts="$( "${thermostat_install_dir}/bin/thermostat" "${thermostat_logging_opts}" help | grep '^ ' | cut -d " " -f 2 | sort | uniq | tr '\n' ' ')"

    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))  
    return 0
}
complete -F _thermostat thermostat