Partially address #13 by adding the `--git <repo>` option to `sandbox create`. This enables the quick cloning of a remote repository instead of doing the tedious dance of creating a sandbox, cloning the remote repo, deleting the sandbox repo them moving the `.git` directory before doing a `git reset --hard HEAD`. Additionally, improve the error messages for all `sandbox` commands, clean up the completions a little, and use a consistent style in the scripts.
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| #compdef sandbox
 | |
| 
 | |
| __sandboxes() {
 | |
|   local -a sandboxes
 | |
|   sandboxes=(${(fo)"$(ls $SANDBOX_ROOT 2> /dev/null)"})
 | |
|   _describe 'in' sandboxes
 | |
| }
 | |
| 
 | |
| _sandbox() {
 | |
|   local context curcontext="$curcontext" state line
 | |
|   typeset -A opt_args
 | |
| 
 | |
|   _arguments -C \
 | |
|       '1: :->cmd' \
 | |
|       '*:: :->args'
 | |
| 
 | |
|   case $state in
 | |
|     (cmd)
 | |
|       local commands; commands=(
 | |
|         'create:Create a new sandbox'
 | |
|         'rename:Rename an existing sandbox'
 | |
|         'destroy:Destroy an existing sandbox'
 | |
|         'list:Show all existing sandboxes'
 | |
|         'enable:Enable an existing sandbox'
 | |
|         'disable:Disable the current sandbox'
 | |
|       )
 | |
|       _describe -t commands 'sandbox command' commands "$@"
 | |
|       ;;
 | |
| 
 | |
|     (args)
 | |
|       curcontext="${curcontext%:*:*}:sandbox-cmd-$words[1]:"
 | |
|       case $line[1] in
 | |
|         (create)
 | |
|           _arguments -C '--git[repository to clone]: :'
 | |
|           ;;
 | |
|         (rename|enable|destroy)
 | |
|           _arguments -C '1:: :__sandboxes'
 | |
|           ;;
 | |
|         (list|disable)
 | |
|           ;;
 | |
|       esac
 | |
|   esac
 | |
| }
 | |
| 
 | |
| _sandbox "$@"
 |