From 61c4d7509841cc3357cb39596957a7dd94ac5b7d Mon Sep 17 00:00:00 2001 From: derwinlu Date: Wed, 1 Apr 2015 21:45:37 +0200 Subject: implement bash autocompletion --- priv/shell-completion/bash/rebar | 89 -------------------- priv/shell-completion/bash/rebar3 | 172 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 89 deletions(-) delete mode 100644 priv/shell-completion/bash/rebar create mode 100644 priv/shell-completion/bash/rebar3 diff --git a/priv/shell-completion/bash/rebar b/priv/shell-completion/bash/rebar deleted file mode 100644 index 375566c..0000000 --- a/priv/shell-completion/bash/rebar +++ /dev/null @@ -1,89 +0,0 @@ -# bash completion for rebar - -_rebar() -{ - local cur prev sopts lopts cmdsnvars - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - sopts="-h -c -v -V -f -D -j -C -p -k -r" - lopts="--help \ - --commands \ - --verbose \ - --force \ - --jobs \ - --config \ - --profile \ - --keep-going \ - --recursive \ - --version" - cmdsnvars="check-deps \ - clean \ - compile \ - create \ - create-app \ - create-lib \ - create-node \ - ct \ - doc \ - delete-deps \ - escriptize \ - eunit \ - get-deps \ - generate \ - generate-appups \ - generate-upgrade \ - help \ - list-deps \ - list-templates \ - prepare-deps \ - qc \ - refresh-deps \ - update-deps \ - version \ - xref \ - overlay \ - apps= \ - case= \ - dump_spec=1 \ - force=1 \ - jobs= \ - suites= \ - verbose=1 \ - appid= \ - overlay_vars= \ - previous_release= \ - nodeid= \ - root_dir= \ - skip_deps=true \ - skip_apps= \ - target_dir= \ - template= \ - template_dir= \ - tests=" - - if [[ ${cur} == --* ]] ; then - COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) ) - elif [[ ${cur} == -* ]] ; then - COMPREPLY=( $(compgen -W "${sopts}" -- ${cur}) ) - else - COMPREPLY=( $(compgen -W "${cmdsnvars}" -- ${cur}) ) - fi - - if [ -n "$COMPREPLY" ] ; then - # append space if matched - COMPREPLY="${COMPREPLY} " - # remove trailing space after equal sign - COMPREPLY=${COMPREPLY/%= /=} - fi - return 0 -} -complete -o nospace -F _rebar rebar - -# Local variables: -# mode: shell-script -# sh-basic-offset: 4 -# sh-indent-comment: t -# indent-tabs-mode: nil -# End: -# ex: ts=4 sw=4 et filetype=sh diff --git a/priv/shell-completion/bash/rebar3 b/priv/shell-completion/bash/rebar3 new file mode 100644 index 0000000..758deee --- /dev/null +++ b/priv/shell-completion/bash/rebar3 @@ -0,0 +1,172 @@ +# bash completion for rebar3 + +_rebar3() +{ + local cur prev sopts lopts cmdsnvars + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + if [[ ${prev} == rebar3 ]] ; then + sopts="-h -v" + lopts="--help --version" + cmdsnvars="as \ + clean \ + compile \ + cover \ + ct \ + dialyzer \ + do \ + edoc \ + escriptize \ + eunit \ + help \ + new \ + pkgs \ + release \ + shell \ + tar \ + update \ + upgrade \ + version \ + wtf \ + xref" + elif [[ ${prev} == as ]] ; then + : + elif [[ ${prev} == clean ]] ; then + sopts="-a" + lopts="--all" + elif [[ ${prev} == compile ]] ; then + : + elif [[ ${prev} == cover ]] ; then + sopts="-r -v" + lopts="--reset --verbose" + elif [[ ${prev} == ct ]] ; then + sopts="-c -v" + lopts="--dir \ + --suite \ + --group \ + --case \ + --spec \ + --join_specs \ + --label \ + --config \ + --userconfig \ + --allow_user_terms \ + --logdir \ + --logopts \ + --verbosity \ + --silent_connections \ + --stylesheet \ + --cover \ + --cover_spec \ + --cover_stop \ + --event_handler \ + --include \ + --abort_if_missing_suites \ + --multiply_timetraps \ + --scale_timetraps \ + --create_priv_dir \ + --repeat \ + --duration \ + --until \ + --force_stop \ + --basic_html \ + --ct_hooks \ + --verbose" + elif [[ ${prev} == dialyzer ]] ; then + sopts="-u -s" + lopts="--update-plt --succ-typings" + elif [[ ${prev} == do ]] ; then + : + elif [[ ${prev} == edoc ]] ; then + : + elif [[ ${prev} == escriptize ]] ; then + : + elif [[ ${prev} == eunit ]] ; then + sopts="-c -v" + lopts="--app --cover --suite --verbose" + elif [[ ${prev} == help ]] ; then + : + elif [[ ${prev} == new ]] ; then + sopts="-f" + lopts="--force" + elif [[ ${prev} == pkgs ]] ; then + : + elif [[ ${prev} == release ]] ; then + sopts="-n -v -g -u -o -h -l -p -V -d -i -a -c -r" + lopts="--relname \ + --relvsn \ + --goal \ + --upfrom \ + --output-dir \ + --help \ + --lib-dir \ + --path \ + --default-libs \ + --verbose \ + --dev-mode \ + --include-erts \ + --override \ + --config \ + --overlay_vars \ + --vm_args \ + --sys_config \ + --system_libs \ + --version \ + --root" + elif [[ ${prev} == shell ]] ; then + : + elif [[ ${prev} == tar ]] ; then + sopts="-n -v -g -u -o -h -l -p -V -d -i -a -c -r" + lopts="--relname \ + --relvsn \ + --goal \ + --upfrom \ + --output-dir \ + --help \ + --lib-dir \ + --path \ + --default-libs \ + --verbose \ + --dev-mode \ + --include-erts \ + --override \ + --config \ + --overlay_vars \ + --vm_args \ + --sys_config \ + --system_libs \ + --version \ + --root" + elif [[ ${prev} == update ]] ; then + : + elif [[ ${prev} == upgrade ]] ; then + : + elif [[ ${prev} == version ]] ; then + : + elif [[ ${prev} == wtf ]] ; then + : + elif [[ ${prev} == xref ]] ; then + : + fi + + COMPREPLY=( $(compgen -W "${sopts} ${lopts} ${cmdsnvars}" -- ${cur}) ) + + if [ -n "$COMPREPLY" ] ; then + # append space if matched + COMPREPLY="${COMPREPLY} " + # remove trailing space after equal sign + COMPREPLY=${COMPREPLY/%= /=} + fi + return 0 +} +complete -o nospace -F _rebar3 rebar3 + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh -- cgit v1.1 From 0ceb3bd6ce302af9a1997a01a3ec6e5408ada364 Mon Sep 17 00:00:00 2001 From: derwinlu Date: Fri, 3 Apr 2015 20:54:38 +0200 Subject: implement zsh completion --- priv/shell-completion/zsh/_rebar | 87 --------------- priv/shell-completion/zsh/_rebar3 | 224 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 224 insertions(+), 87 deletions(-) delete mode 100644 priv/shell-completion/zsh/_rebar create mode 100644 priv/shell-completion/zsh/_rebar3 diff --git a/priv/shell-completion/zsh/_rebar b/priv/shell-completion/zsh/_rebar deleted file mode 100644 index 0218f9e..0000000 --- a/priv/shell-completion/zsh/_rebar +++ /dev/null @@ -1,87 +0,0 @@ -#compdef rebar - -local curcontext=$curcontext state ret=1 -typeset -ga _rebar_global_opts - -_rebar_global_opts=( - '(--help -h)'{--help,-h}'[Show the program options]' - '(--commands -c)'{--commands,-c}'[Show available commands]' - '(--version -V)'{--version,-V}'[Show version information]' - '(-vv -v)'--verbose'[Enforce verbosity level]' - '(-vv)-v[Slightly more verbose output]' - '(-v)-vv[More verbose output]' - '(-vv -v --verbose)'{--quiet,-q}'[Quiet, only print error messages]' - '(--force -f)'{--force,-f}'[Force]' - '-D+[Define compiler macro]' - '(--jobs -j)'{--jobs+,-j+}'[Number of concurrent workers a command may use. Default: 3]:workers:(1 2 3 4 5 6 7 8 9)' - '(--config -C)'{--config,-C}'[Rebar config file to use]:files:_files' - '(--profile -p)'{--profile,-p}'[Profile this run of rebar]' - '(--keep-going -k)'{--keep-going,-k}'[Keep running after a command fails]' - '(--recursive -r)'{--recursive,-r}'[Apply commands to subdirs and dependencies]' -) - -_rebar () { - _arguments -C $_rebar_global_opts \ - '*::command and variable:->cmd_and_var' \ - && return - - case $state in - cmd_and_var) - _values -S = 'variables' \ - 'clean[Clean]' \ - 'compile[Compile sources]' \ - 'create[Create skel based on template and vars]' \ - 'create-app[Create simple app skel]' \ - 'create-lib[Create simple lib skel]' \ - 'create-node[Create simple node skel]' \ - 'list-template[List avaiavle templates]' \ - 'doc[Generate Erlang program documentation]' \ - 'check-deps[Display to be fetched dependencies]' \ - 'prepare-deps[Fetch and build dependencies]' \ - 'refresh-deps[Update and build dependencies]' \ - 'get-deps[Fetch dependencies]' \ - 'update-deps[Update fetched dependencies]' \ - 'delete-deps[Delete fetched dependencies]' \ - 'list-deps[List dependencies]' \ - 'generate[Build release with reltool]' \ - 'overlay[Run reltool overlays only]' \ - 'generate-appups[Generate appup files]' \ - 'generate-upgrade[Build an upgrade package]' \ - 'escriptize[Create stand-alone escript executable]' \ - 'eunit[Run eunit tests]' \ - 'ct[Run common_test suites]' \ - 'qc[Test QuickCheck properties]' \ - 'xref[Run cross reference analysis]' \ - 'help[Show the program options]' \ - 'version[Show version information]' \ - 'apps[Application names to process]:' \ - 'case[Common Test case]:' \ - 'dump_spec[Dump reltool spec]::flag:(1)' \ - 'jobs[Number of workers]::workers:(0 1 2 3 4 5 6 7 8 9)' \ - 'suites[Common Test suites]::suite name:_path_files -W "(src test)" -g "*.erl(:r)"' \ - 'verbose[Verbosity level]::verbosity level:(0 1 2 3)' \ - 'appid[Application id]:' \ - 'overlay_vars[Overlay variables file]:' \ - 'previous_release[Previous release path]:' \ - 'nodeid[Node id]:' \ - 'root_dir[Reltool config root directory]::directory:_files -/' \ - 'skip_deps[Skip deps]::flag:(true false)' \ - 'skip_apps[Application names to not process]::flag:(true false)' \ - 'target_dir[Target directory]:' \ - 'template[Template name]:' \ - 'template_dir[Template directory]::directory:_files -/' \ - 'tests[Run eunit tests whose name starts with given string]:' \ - && ret=0 - ;; - esac -} - -_rebar - -# Local variables: -# mode: shell-script -# sh-basic-offset: 2 -# sh-indent-comment: t -# indent-tabs-mode: nil -# End: -# ex: sw=2 ts=2 et filetype=sh diff --git a/priv/shell-completion/zsh/_rebar3 b/priv/shell-completion/zsh/_rebar3 new file mode 100644 index 0000000..4566eda --- /dev/null +++ b/priv/shell-completion/zsh/_rebar3 @@ -0,0 +1,224 @@ +#compdef rebar3 + + + +_rebar3 () { + typeset -A opt_args + local curcontext="$curcontext" state line + + local ret=1 + + _arguments -C \ + '1: :_rebar3_tasks' \ + '*::arg:->args' \ + && ret=0 + + case $state in + (args) + curcontext="${curcontext%:*:*}:rebar-task-$words[1]:" + case $line[1] in + (as) + _arguments \ + '1:name' \ + '2: :_rebar3_tasks' \ + && ret=0 + ;; + (clean) + _arguments \ + '(-a --all)'{-a,--all}'[Clean all apps include deps.]' \ + && ret=0 + ;; + (compile) + _message 'no more arguments' && ret=0 + ;; + (cover) + _arguments \ + '(-r --reset)'{-r,--reset}'[Reset all coverdata.]' \ + '(-v --verbose)'{-v,--verbose}'[Print coverage analysis.]' \ + && ret=0 + ;; + (ct) + _arguments \ + '(--dir)--dir[List of additional directories containing test suites]:test directory:_files -/' \ + '(--suite)--suite[List of test suites to run]:suites' \ + '(--group)--group[List of test groups to run]:groups' \ + '(--case)--case[List of test cases to run]:cases' \ + '(--spec)--spec[List of test specs to run]:specs' \ + '(--join_specs)--join_specs' \ + '(--label)--label[Test label]:label' \ + '(--config)--config[List of config files]:config files:_files' \ + '(--userconfig)--userconfig' \ + '(--allow_user_terms)--allow_user_terms' \ + '(--logdir)--logdir[Log folder]:log folder:_files -/' \ + '(--logopts)--logopts' \ + '(--verbosity)--verbosity[Verbosity]:verbosity' \ + '(--silent_connections)--silent_connections' \ + '(--stylesheet)--stylesheet[Stylesheet to use for test results]:stylesheet:_files' \ + '(-c --cover)'{-c,--cover}'[Generate cover data]' \ + '(--cover_spec)--cover_spec[Cover file to use]:cover file:_files' \ + '(--cover_stop)--cover_stop' \ + '(--event_handler)--event_handler[Event handlers to attach to the runner]:event handlers' \ + '(--include)--include[Include folder]:include directory:_files -/' \ + '(--abort_if_missing_suites)--abort_if_missing_suites[Abort if suites are missing]:abort missing suites:(true false)' \ + '(--multiply_timetraps)--multiply_timetraps' \ + '(--scale_timetraps)--scale_timetraps' \ + '(--create_priv_dir)--create_priv_dir' \ + '(--repeat)--repeat[How often to repeat tests]:repeat test count' \ + '(--duration)--duration[Max runtime (format: HHMMSS)]:max run time' \ + '(--until)--until[Run until (format: HHMMSS)]:run until time' \ + '(--force_stop)--force_stop[Force stop after time]' \ + '(--basic_html)--basic_html[Show basic HTML]' \ + '(--ct_hooks)--ct_hooks:ct hooks' \ + '(-v --verbose)'{-v,--verbose}'[Print coverage analysis]' \ + && ret=0 + ;; + (dialyzer) + _arguments \ + '(-u --update-plt)'{-u, --update-plt}'[Enable updating the PLT.]' \ + '(-s --succ-typings)'{-s, --succ-typings}'[Enable success typing analysis.]' \ + && ret=0 + ;; + (do) + _message 'rebar do' && ret=0 + ;; + (edoc) + _message 'rebar edoc' && ret=0 + ;; + (escriptize) + _message 'rebar escriptize' && ret=0 + ;; + (eunit) + _arguments \ + '(--app)--app[List of application test suites to run]:suites' \ + '(--suite)--suite[List of test suites to run]:suites' \ + '(-c --cover)'{-c,--cover}'[Generate cover data]' \ + '(-v --verbose)'{-v,--verbose}'[Verbose output]' \ + && ret=0 + ;; + (help) + _arguments '1: :_rebar3_tasks' && ret=0 + ;; + (new) + _arguments \ + '1:type:(app lib release plugin)' \ + '2:name:' \ + '(-f --force)'{-f,--force}'[ overwrite existing files]' \ + && ret=0 + ;; + (pkgs) + _message 'List available packages.' && ret=0 + ;; + (release) + _arguments \ + '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \ + '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \ + '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \ + '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \ + '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \ + '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \ + '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \ + '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \ + '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \ + '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \ + '(-i --include-erts)'{-i,--dev-mode}'[If true include a copy of erts used to build with, if a path include erts at that path. If false, do not include erts]' \ + '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form :]:override' \ + '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \ + '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \ + '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \ + '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \ + '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \ + '(--version)--version[Print relx version]' \ + '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \ + && ret=0 + ;; + (shell) + _message 'Start a shell with project and deps preloaded' && ret=0 + ;; + (tar) + _arguments \ + '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \ + '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \ + '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \ + '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \ + '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \ + '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \ + '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \ + '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \ + '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \ + '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \ + '(-i --include-erts)'{-i,--dev-mode}'[If true include a copy of erts used to build with, if a path include erts at that path. If false, do not include erts]' \ + '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form :]:override' \ + '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \ + '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \ + '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \ + '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \ + '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \ + '(--version)--version[Print relx version]' \ + '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \ + && ret=0 + ;; + (update) + _message 'rebar update' && ret=0 + ;; + (upgrade) + _arguments \ + '*: :_rebar3_list_deps' \ + && ret=0 + ;; + (version) + _message 'rebar version' && ret=0 + ;; + (wtf) + _arguments '1: :_rebar3_tasks' && ret=0 + ;; + (xref) + _message 'rebar xref' && ret=0 + esac + esac +} + +(( $+functions[_rebar3_tasks] )) || +_rebar3_tasks() { + local tasks; tasks=( + 'as:Higher order provider for running multiple tasks in a sequence as a certain profiles.' + 'clean:Remove compiled beam files from apps.' + 'compile:Compile apps .app.src and .erl files.' + 'cover:Perform coverage analysis.' + 'ct:Run Common Tests.' + 'dialyzer:Run the Dialyzer analyzer on the project.' + 'do:Higher order provider for running multiple tasks in a sequence.' + 'edoc:Generate documentation using edoc.' + 'escriptize:Generate escript archive.' + 'eunit:Run EUnit Tests.' + 'help:Display a list of tasks or help for a given task or subtask.' + 'new:Create new project from templates.' + 'pkgs:List available packages.' + 'release:Build release of project.' + 'shell:Run shell with project apps and deps in path.' + 'tar:Tar archive of release built of project.' + 'update:Update package index.' + 'upgrade:Upgrade dependencies.' + 'version:Print version for rebar and current Erlang.' + 'wtf:Provide a crash report to be sent to the rebar3 issues page.' + 'xref:Run cross reference analysis.' + ) + _describe -t tasks 'rebar3 tasks' tasks "$@" +} + +(( $+functions[_rebar3_list_deps] )) || +_rebar3_list_deps() { + local -a cmd packages deps_long + deps_long=($PWD/deps/*(/)) + packages=( ${${deps_long#$PWD/deps/}%-*-*} ) + compadd "$@" -a packages +} + +_rebar3 "$@" + +# Local variables: +# mode: shell-script +# sh-basic-offset: 2 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: sw=2 ts=2 et filetype=sh -- cgit v1.1