Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions bin/build-all
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ createRelease() {
binname="$binname.exe"
fi

relname="../release/$BINNAME-$osname-$osarch"
echo "Creating $os/$arch binary..."

if [ "$arm" ]
Expand All @@ -62,15 +61,12 @@ createRelease() {
GOOS=$os GOARCH=$arch go build -ldflags "$ldflags" -o "out/$binname" exercism/main.go
fi

cd out

if [ "$osname" = windows ]
then
zip "$relname.zip" "$binname"
release_name="release/$BINNAME-$osname-$osarch"
if [ "$osname" = windows ]; then
(cd out && zip "../$release_name.zip" ../shell/* "./$binname")
else
tar cvzf "$relname.tgz" "$binname"
tar cvzf "$release_name.tgz" shell -C out "./$binname"
fi
cd ..
}

# Mac Releases
Expand Down
30 changes: 30 additions & 0 deletions shell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Executable
Unpack the archive relevant to your machine and place in $PATH

## Shell Completion Scripts

### Bash

mkdir -p ~/.config/exercism
mv ../shell/exercism_completion.bash ~/.config/exercism/exercism\exercism_completion.bash

Load the completion in your `.bashrc`, `.bash_profile` or `.profile` by
adding the following snippet:

if [ -f ~/.config/exercism/exercism_completion.bash ]; then
source ~/.config/exercism/exercism_completion.bash
fi

### Zsh

mkdir -p ~/.config/exercism
mv ../shell/exercism_completion.zsh ~/.config/exercism/exercism_completion.zsh

Load up the completion in your `.zshrc`, `.zsh_profile` or `.profile` by adding
the following snippet

if [ -f ~/.config/exercism/exercism_completion.zsh ]; then
source ~/.config/exercism/exercism_completion.zsh
fi

**Note:** If you are using the popular [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) framework to manage your zsh plugins, you don't need to add the above snippet, all you need to do is create a file `exercism_completion.zsh` inside the `~/.oh-my-zsh/custom`.
71 changes: 71 additions & 0 deletions shell/exercism_completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
_exercism () {
local cur prev

COMPREPLY=() # Array variable storing the possible completions.
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}

commands="configure debug download fetch list open
restore skip status submit tracks unsubmit
upgrade help"
tracks="csharp cpp clojure coffeescript lisp crystal
dlang ecmascript elixir elm elisp erlang
fsharp go haskell java javascript kotlin
lfe lua mips ocaml objective-c php
plsql perl5 python racket ruby rust scala
scheme swift typescript bash c ceylon
coldfusion delphi factor groovy haxe
idris julia nim perl6 pony prolog
purescript r sml vbnet powershell"
config_opts="--dir --host --key --api"
submit_opts="--test --comment"

if [ "${#COMP_WORDS[@]}" -eq 2 ]; then
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
return 0
fi

if [ "${#COMP_WORDS[@]}" -eq 3 ]; then
case "${prev}" in
configure)
COMPREPLY=( $( compgen -W "${config_opts}" -- "${cur}" ) )
return 0
;;
fetch)
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
return 0
;;
list)
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
return 0
;;
open)
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
return 0
;;
skip)
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
return 0
;;
status)
COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) )
return 0
;;
submit)
COMPREPLY=( $( compgen -W "${submit_opts}" -- "${cur}" ) )
return 0
;;
help)
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
return 0
;;
*)
return 0
;;
esac
fi

return 0
}

complete -F _exercism exercism
38 changes: 38 additions & 0 deletions shell/exercism_completion.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
_exercism() {
local curcontext="$curcontext" state line
typeset -A opt_args

local -a options
options=(debug:"Outputs useful debug information."
configure:"Writes config values to a JSON file."
demo:"Fetches a demo problem for each language track on exercism.io."
fetch:"Fetches your current problems on exercism.ios well as the next unstarted problem in each language."
restore:"Restores completed and current problems on from exercism.iolong with your most recent iteration for each."
submit:"Submits a new iteration to a problem on exercism.io."
unsubmit:"Deletes the most recently submitted iteration."
tracks:"List the available language tracks"
download:"Downloads and saves a specified submission into the local system"
help:"Shows a list of commands or help for one command")

_arguments -s -S \
{-c,--config}"[path to config file]:file:_files" \
{-d,--debug}"[turn on verbose logging]" \
{-h,--help}"[show help]" \
{-v,--version}"[print the version]" \
'(-): :->command' \
'(-)*:: :->option-or-argument' \
&& return 0;

case $state in
(command)
_describe 'commands' options ;;
(option-or-argument)
case $words[1] in
s*)
_files
;;
esac
esac
}

compdef '_exercism' exercism