#compdef ember

local curcontext="$curcontext" state line ret=1

_arguments -C -A "--version" -A "--help" \
  '(- 1 *)--help' \
  '(- 1 *)--version' \
  '1: :->cmds' \
  '*:: :->args' && ret=0

case $state in
  cmds)
    _values "ember command" \
      "addon[Generates a new folder structure for building an addon, complete with test harness]" \
      "asset-sizes[Shows the sizes of your asset files]" \
      "build[Builds your app and places it into the output path (dist/ by default)]" \
      "destroy[Destroys code generated by generate command]" \
      "generate[Generates new code from blueprints]" \
      "help[Outputs the usage instructions for all commands or the provided command]" \
      "init[Creates a new ember-cli project in the current folder]" \
      "install[Installs an ember-cli addon from npm]" \
      "new[Creates a new directory and runs ember init in it]" \
      "serve[Builds and serves your app, rebuilding on file changes]" \
      "test[Runs your app's test suite]" \
      "version[outputs ember-cli version]"
    ret=0
    ;;
  args)
    case $line[1] in
      help)
        _values 'commands' \
          'addon' \
          'asset-sizes' \
          'build' \
          'destroy' \
          'generate' \
          'help' \
          'init' \
          'install' \
          'new' \
          'serve' \
          'test' \
          'vesion' && ret=0
        ;;
      addon)
        _arguments \
          '(--blueprint)--blueprint=-' \
          '(--directory)--directory=-' \
          '(--dry-run)--dry-run' \
          '(--skip-bower)--skip-bower' \
          '(--skip-git)--skip-git' \
          '(--skip-npm)--skip-npm' \
          '(--verbose)--verbose'
        ;;
      asset-sizes)
        _arguments \
          '(--output-path)--output-path=-'
        ;;
      build)
        _arguments \
          '(--environment)--environment=-' \
          '(--output-path)--output-path=-' \
          '(--output-path)--suppress-sizes' \
          '(--watch)--watch' \
          '(--watcher)--watcher=-' \
          '(-dev)-dev' \
          '(-prod)-prod'
        ;;
      destroy|generate)
        _values 'arguments' \
          '(--classic)--classic' \
          '(--dry-run)--dry-run' \
          '(--dummy)--dummy' \
          '(--in-repo-addon)--in-repo-addon-=' \
          '(--pod)--pod' \
          '(--verbose)--verbose' && ret=0
        _values 'blueprints' \
          'acceptance-test' \
          'adapter' \
          'adapter-test' \
          'component' \
          'component-addon' \
          'component-test' \
          'controller' \
          'controller-test' \
          'helper' \
          'helper-addon' \
          'helper-test' \
          'initializer' \
          'initializer-addon' \
          'initializer-test' \
          'instance-initializer' \
          'instance-initializer-addon' \
          'instance-initializer-test' \
          'mixin' \
          'mixin-test' \
          'model' \
          'model-test' \
          'resource' \
          'route' \
          'route-addon' \
          'route-test' \
          'serializer' \
          'serializer-test' \
          'service' \
          'service-test' \
          'template' \
          'test-helper' \
          'transform' \
          'transform-test' \
          'util' \
          'util-test' \
          'view' \
          'view-test' \
          'addon' \
          'addon-import' \
          'app' \
          'blueprint' \
          'http-mock' \
          'http-proxy' \
          'in-repo-addon' \
          'lib' \
          'server' \
          'vendor-shim' && ret=0
        ;;
      init)
        _arguments \
          '(--blueprint)--blueprint=-' \
          '(--name)--name=-' \
          '(--dry-run)--dry-run' \
          '(--skip-bower)--skip-bower' \
          '(--skip-npm)--skip-npm' \
          '(--verbose)--verbose'
        ;;
      install)
        _arguments \
          '(--save-dev)--save-dev' \
          '(--save)--save'
        ;;
      new)
        _arguments \
          '(--blueprint)--blueprint=-' \
          '(--directory)--directory=-' \
          '(--dry-run)--dry-run' \
          '(--skip-bower)--skip-bower' \
          '(--skip-git)--skip-git' \
          '(--skip-npm)--skip-npm' \
          '(--verbose)--verbose'
        ;;
      serve)
        _arguments \
          '(--port)--port=-[To use a port different than 4200. Pass 0 to automatically pick an available port.]' \
          '(--host)--host=-[Listens on all interfaces by default]' \
          '(--proxy)--proxy=-' \
          '(--secure-proxy)--secure-proxy[Set to false to proxy self-signed SSL certificates]' \
          '(--transparent-proxy)--transparent-proxy[Set to false to omit x-forwarded-* headers when proxying]' \
          '(--watcher)--watcher=-' \
          '(--live-reload)--live-reload' \
          '(--live-reload-host)--live-reload-host=-[Defaults to host]' \
          '(--live-reload-base-url)--live-reload-base-url=-[Defaults to baseURL]' \
          '(--live-reload-port)--live-reload-port=-[Defaults to port number within \[49152...65535\]]' \
          '(--environment)--environment=-' \
          '(--output-path)--output-path=-' \
          '(--ssl)--ssl' \
          '(--ssl-key)--ssl-key=-' \
          '(--ssl-cert)--ssl-cert=-'
        ;;
      test)
        _arguments \
          '(--environment)--environment=-' \
          '(--config-file)--config-file=-' \
          '(--server)--server' \
          '(--host)--host=-' \
          '(--test-port)--test-port=-[The test port to use when running with --server.]' \
          '(--filter)--filter=-[A string to filter tests to run]' \
          '(--module)--module=-[The name of a test module to run]' \
          '(--watcher)--watcher=-' \
          '(--launch)--launch=-[A comma separated list of browsers to launch for tests.]' \
          '(--reporter)--reporter=-[Test reporter to use \[tap|dot|xunit\] (default: tap)]' \
          '(--silent)--silent[Suppress any output except for the test report]' \
          '(--test-page)--test-page=-[Test page to invoke]' \
          '(--path)--path=-[Reuse an existing build at given path.]' \
          '(--query)--query=-[A query string to append to the test page URL.]'
        ;;
    esac
    ;;
esac

return ret