Skip to content

Commit

Permalink
Import bash completion script for caffe from Debian Package.
Browse files Browse the repository at this point in the history
Imported from Debian Package caffe (1.0.0~rc3+20160715-g42cd785-2).
  • Loading branch information
cdluminate committed Aug 10, 2016
1 parent 375003a commit 42d20fe
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions scripts/caffe
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# bash completion for Caffe's command line utility -*- shell-script -*-
# COPYRIGHT (C) 2015,2016 Zhou Mo <[email protected]>
# License: BSD-2-Clause
# Originally appeard at https://github.com/BVLC/caffe/issues/3149

# Updated for caffe (1.0.0~rc3+20160715-g42cd785)
_caffe()
{
local cur prev words cword
_init_completion -s || return

local prototxts='@(prototxt)'
local caffemodels='@(caffemodel,binaryproto)'
local solverstates='@(solverstate)'
local caffefiles='@(prototxt|caffemodel|solverstate)'

local flags='-gpu -iterations -model -snapshot -solver -weights -sighup_effect -sigint_effect -level -stage -phase'

if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'train test time device_query' -- "$cur" ) )
return 0
fi

if [[ $cword -eq 2 ]]; then
case ${words[1]} in
train|test|device_query|time)
COMPREPLY=( $( compgen -W "$flags" -- "$cur") )
return 0
;;
*)
return 0
;;
esac
fi

case $prev in
-gpu|-iterations|-version|-level|-stage)
return 0
;;
-solver|-model)
_filedir $prototxts
return 0
;;
-weights)
_filedir $caffemodels
return 0
;;
-snapshot)
_filedir $solverstates
return 0
;;
-sighup_effect|-sigint_effect)
COMPREPLY=( $( compgen -W 'snapshot stop none' -- "$cur") )
return 0
;;
-phase)
COMPREPLY=( $( compgen -W 'TRAIN TEST' -- "$cur") )
return 0
;;
*)
COMPREPLY=( $( compgen -W "$flags" -- "$cur") )
return 0
;;
esac

# file completion on relevant files
_filedir "$caffefiles"

return 0
}
complete -F _caffe caffe

# vim

0 comments on commit 42d20fe

Please sign in to comment.