Skip to content

Commit 4ae3f85

Browse files
author
Katrina Owen
authored
Merge pull request #759 from nywilken/tab-completion-update
Update shell tab completion for exercism cli
2 parents 97d69cc + 517f301 commit 4ae3f85

File tree

2 files changed

+26
-44
lines changed

2 files changed

+26
-44
lines changed

shell/exercism_completion.bash

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@ _exercism () {
44
COMPREPLY=() # Array variable storing the possible completions.
55
cur=${COMP_WORDS[COMP_CWORD]}
66
prev=${COMP_WORDS[COMP_CWORD-1]}
7+
opts="--verbose --timeout"
78

8-
commands="configure debug download fetch list open
9-
restore skip status submit tracks unsubmit
10-
upgrade help"
11-
tracks="csharp cpp clojure coffeescript lisp crystal
12-
dlang ecmascript elixir elm elisp erlang
13-
fsharp go haskell java javascript kotlin
14-
lfe lua mips ocaml objective-c php
15-
plsql perl5 python racket ruby rust scala
16-
scheme swift typescript bash c ceylon
17-
coldfusion delphi factor groovy haxe
18-
idris julia nim perl6 pony prolog
19-
purescript r sml vbnet powershell"
20-
config_opts="--dir --host --key --api"
21-
submit_opts="--test --comment"
9+
commands="configure download open
10+
submit troubleshoot upgrade version workspace help"
11+
config_opts="--show"
12+
version_opts="--latest"
2213

2314
if [ "${#COMP_WORDS[@]}" -eq 2 ]; then
24-
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
25-
return 0
15+
case "${cur}" in
16+
-*)
17+
COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
18+
return 0
19+
;;
20+
*)
21+
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
22+
return 0
23+
;;
24+
esac
2625
fi
2726

2827
if [ "${#COMP_WORDS[@]}" -eq 3 ]; then
@@ -31,28 +30,8 @@ _exercism () {
3130
COMPREPLY=( $( compgen -W "${config_opts}" -- "${cur}" ) )
3231
return 0
3332
;;
34-
fetch)
35-
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
36-
return 0
37-
;;
38-
list)
39-
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
40-
return 0
41-
;;
42-
open)
43-
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
44-
return 0
45-
;;
46-
skip)
47-
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
48-
return 0
49-
;;
50-
status)
51-
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
52-
return 0
53-
;;
54-
submit)
55-
COMPREPLY=( $( compgen -W "${submit_opts}" -- "${cur}" ) )
33+
version)
34+
COMPREPLY=( $( compgen -W "${version_opts}" -- "${cur}" ) )
5635
return 0
5736
;;
5837
help)

shell/exercism_completion.zsh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ _exercism() {
33
typeset -A opt_args
44

55
local -a options
6-
options=(debug:"Outputs useful debug information."
7-
configure:"Writes config values to a JSON file."
8-
submit:"Submits a new iteration to a problem on exercism.io."
6+
options=(configure:"Writes config values to a JSON file."
97
download:"Downloads and saves a specified submission into the local system"
8+
open:"Opens a browser to exercism.io for the specified submission."
9+
submit:"Submits a new iteration to a problem on exercism.io."
10+
troubleshoot:"Outputs useful debug information."
11+
upgrade:"Upgrades to the latest available version."
12+
version:"Outputs version information."
13+
workspace:"Outputs the root directory for Exercism exercises."
1014
help:"Shows a list of commands or help for one command")
1115

1216
_arguments -s -S \
13-
{-c,--config}"[path to config file]:file:_files" \
14-
{-d,--debug}"[turn on verbose logging]" \
1517
{-h,--help}"[show help]" \
16-
{-v,--version}"[print the version]" \
18+
{-t,--timeout}"[override default HTTP timeout]" \
19+
{-v,--verbose}"[turn on verbose logging]" \
1720
'(-): :->command' \
1821
'(-)*:: :->option-or-argument' \
1922
&& return 0;

0 commit comments

Comments
 (0)