#compdef netctl-gui
###########################################################################
#   This file is part of netctl-gui                                       #
#                                                                         #
#   netctl-gui is free software: you can redistribute it and/or           #
#   modify it under the terms of the GNU General Public License as        #
#   published by the Free Software Foundation, either version 3 of the    #
#   License, or (at your option) any later version.                       #
#                                                                         #
#   netctl-gui is distributed in the hope that it will be useful,         #
#   but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#   GNU General Public License for more details.                          #
#                                                                         #
#   You should have received a copy of the GNU General Public License     #
#   along with netctl-gui. If not, see http://www.gnu.org/licenses/       #
###########################################################################


# variables
_netctl_gui_arglist=(
    {'--detached','--detached'}'[start detached from console]'
    {'--maximized','--maximized'}'[start maximized]'
    {'--minimized','--minimized'}'[start minimized to tray]'
    {'--about','--about'}'[show about window]'
    {'--netctl-auto','--netctl-auto'}'[show netctl-auto window]'
    {'--settings','--settings'}'[show settings window]'
    {'(--essid)-e','(-e)--essid'}'[select ESSID]:type ESSID:->essid'
    {'(--open)-o','(-o)--open'}'[open profile]:select profile:->profiles'
    {'(--select)-s','(-s)--select'}'[select profile]:select profile:->profiles'
    {'(--config)-c','(-c)--config'}'[read configuration from this file]:select file:->files'
    {'(--debug)-d','(-d)--debug'}'[print debug information]'
    {'--default','--default'}'[start with default settings]'
    {'--set-opts','--set-opts'}'[set options for this run, comma separated]:comma separated:->settings'
    {'(--tab)-t','(-t)--tab'}'[open a tab with specified number]:select tab:->tab'
    {'(--version)-v','(-v)--version'}'[show version and exit]'
    {'(--info)-i','(-i)--info'}'[show build information and exit]'
    {'(--help)-h','(-h)--help'}'[show help and exit]'
)

_netctl_gui_settings=(
    'CLOSE_HELPER'
    'CLOSETOTRAY'
    'CTRL_DIR'
    'CTRL_GROUP'
    'FORCE_SUDO'
    'HELPER_PATH'
    'HELPER_SERVICE'
    'IFACE_DIR'
    'LANGUAGE'
    'NETCTL_PATH'
    'NETCTLAUTO_PATH'
    'NETCTLAUTO_SERVICE'
    'PID_FILE'
    'PREFERED_IFACE'
    'PROFILE_DIR'
    'RFKILL_DIR'
    'SKIPCOMPONENTS'
    'STARTTOTRAY'
    'SUDO_PATH'
    'SYSTEMCTL_PATH'
    'SYSTRAY'
    'USE_HELPER'
    'WPACLI_PATH'
    'WPASUP_PATH'
    'WPA_DRIVERS'
)

_netctl_gui_tabs=(
    '1'
    '2'
    '3'
)

_netctl_profiles() {
    print $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}


# work block
_netctl-gui() {
    _arguments $_netctl_gui_arglist
    case "$state" in
        essid)
            ;;
        files)
            _files
            ;;
        profiles)
            _values 'profiles' $(_netctl_profiles)
            ;;
        settings)
            _values -s ',' 'settings' $_netctl_gui_settings
            ;;
        tab)
            _values 'tab' $_netctl_gui_tabs
            ;;
    esac
}

case "$service" in
    netctl-gui)
        _netctl-gui "$@" && return 0
        ;;
esac