#compdef disi

# Copyright C 2002-2010 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.

# redefine _disi

_disi () {
  _arguments \
    - help \
      '-h' \
    - nonhelp \
      '*::disi command:_disi_command'
}

(( $+functions[_disi_command] )) ||
_disi_command() {
  if (( ! $+_disi_cmds )); then
    typeset -gA _disi_cmds
    _disi_cmds=(
       diskpools a
       hwhealth a
    )
  fi

  if (( CURRENT == 1 )); then
    _tags commands && { compadd "$@" -k _disi_cmds || compadd "$@" ${(kv)=_disi_cmds} }
  else
    local curcontext="$curcontext"
    cmd="${${(k)_disi_cmds[(R)* $words[1] *]}:-${(k)_disi_cmds[(i)$words[1]]}}"
    if (( $#cmd )); then
      curcontext="${curcontext%:*:*}:disi-${cmd}:"
      _disi_$cmd
    else
      _message "unknown disi command: $words[1]"
    fi
  fi
}

_disi "$@"
