#compdef places

autoload -U is-at-least

_places() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-a+[Optional program to get paths]:program:_command_names -e' \
'--app=[Optional program to get paths]:program:_command_names -e' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
':location -- The (XDG) location.:((home\:"HOME                         /home/alice"
desktop\:"XDG_DESKTOP_DIR              /home/alice/Desktop"
downloads\:"XDG_DOWNLOAD_DIR             /home/alice/Downloads"
templates\:"XDG_TEMPLATES_DIR            /home/alice/Templates"
documents\:"XDG_DOCUMENTS_DIR            /home/alice/Documents"
pictures\:"XDG_PICTURES_DIR             /home/alice/Pictures"
videos\:"XDG_VIDEOS_DIR               /home/alice/Videos"
music\:"XDG_MUSIC_DIR                /home/alice/Music"
public\:"XDG_PUBLICSHARE_DIR          /home/alice/Public "
config\:"XDG_CONFIG_HOME               /home/alice/.config"
bin\:"XDG_BIN_HOME                  /home/alice/.local/bin"
cache\:"XDG_CACHE_HOME                /home/alice/.cache"
state\:"XDG_STATE_HOME                /home/alice/.state"
data\:"XDG_DATA_HOME                 /home/alice/.local/share  Note\: You always get expanded paths and not paths starting with ~."
autostart\:"XDG_CONFIG_HOME/autostart     ~/.config/autostart"
fonts\:"XDG_DATA_HOME/fonts           ~/.local/share/fonts"
menus\:"XDG_DATA_HOME/applications    ~/.local/share/applications"
backgrounds\:"XDG_DATA_HOME/backgrounds     ~/.local/share/backgrounds"
icons\:"XDG_DATA_HOME/icons           ~/.local/share/icons"))' \
'*::files -- Optional list of path elements to append:' \
&& ret=0
}

(( $+functions[_places_commands] )) ||
_places_commands() {
    local commands; commands=()
    _describe -t commands 'places commands' commands "$@"
}

if [ "$funcstack[1]" = "_places" ]; then
    _places "$@"
else
    compdef _places places
fi
