From 0ce85b45a2bc696a2e9efa54542e5571706fa3f0 Mon Sep 17 00:00:00 2001 From: Han Ngo Date: Sat, 23 Jan 2016 20:27:26 +0700 Subject: [PATCH] Add completion for Elixir mix --- src/_mix | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 src/_mix diff --git a/src/_mix b/src/_mix new file mode 100644 index 0000000..1ab8b03 --- /dev/null +++ b/src/_mix @@ -0,0 +1,138 @@ +#compdef mix +#autoload + +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Elixir Mix +# +# Last updated: 23.01.2016 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Han Ngo (https://github.com/tieubao) +# +# ------------------------------------------------------------------------------ + +local -a _1st_arguments +_1st_arguments=( + 'app.start:Start all registered apps' + 'archive:List all archives' + 'archive.build:Archive this project into a .ez file' + 'archive.install:Install an archive locally' + 'archive.uninstall:Uninstall archives' + 'clean:Delete generated application files' + 'cmd:Executes the given command' + 'compile:Compile source files' + 'compile.protocols:Consolidates all protocols in all paths' + 'deps:List dependencies and their status' + "deps.clean:Remove the given dependencies' files" + 'deps.compile:Compile dependencies' + 'deps.get:Get all out of date dependencies' + 'deps.unlock:Unlock the given dependencies' + 'deps.update:Update the given dependencies' + 'do:Executes the tasks separated by comma' + 'ecto.create:Create the storage for the repo' + 'ecto.drop:Drop the storage for the repo' + 'ecto.gen.migration:Generate a new migration for the repo' + 'ecto.gen.repo:Generate a new repository' + 'ecto.migrate:Run migrations up on a repo' + 'ecto.rollback:Rollback migrations from a repo' + 'escript.build:Builds an escript for the project' + 'gettext.extract:Get text extract' + 'gettext.merge:Get text merge' + 'help:Print help information for tasks' + 'hex:Print hex help information' + 'hex.build:Builds a new package version locally' + 'hex.config:Read or update hex config' + 'hex.docs:Publish docs for package' + 'hex.info:Print hex information' + 'hex.key:Hex API key tasks' + 'hex.outdated:Shows outdated hex deps for the current project' + 'hex.owner:Hex package ownership tasks' + 'hex.publish:Publish a new package version' + 'hex.registry:Hex registry tasks' + 'hex.search:Search for package names' + 'hex.user:Hex user tasks' + 'loadconfig:Loads and persists the given configuration' + 'local:List local tasks' + 'local.hex:Install hex locally' + 'local.public_keys:Public keys' + 'local.rebar:Install rebar locally' + 'new:Create a new Elixir project' + 'phoenix.digest:Digests and compress static files' + 'phoenix.gen.channel:Generates a Phoenix channel' + 'phoenix.gen.html:Generates controller, model and views for an HTML based resource' + 'phoenix.gen.json:Generates a controller and model for a JSON based resource' + 'phoenix.gen.model:Generates an Ecto model' + 'phoenix.gen.secret:Generates a secret' + 'phoenix.new:Create a new Phoenix application' + 'phoenix.routes:Prints all routes' + 'phoenix.server:Starts applications and their servers' + 'profile.fprof:Profiles the given file or expression with fprof' + 'run:Run the given file or expression' + "test:Run a project's tests" + '--help:Describe available tasks' + '--version:Prints the Elixir version information' +) + +__task_list () +{ + local expl + declare -a tasks + + tasks=$(mix --help | grep -v "default task" | awk '{print $2}') + + _wanted tasks expl 'help' compadd $tasks +} + +local expl + +local curcontext="$curcontext" state line +typeset -A opt_args + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "mix subcommand" _1st_arguments + return + ;; + + (options) + case $line[1] in + (help) + _arguments ':feature:__task_list' + esac + ;; +esac