Further work on Barry USB channel relaying. This is mostly just adding debug output...
[barry.git] / bash / bjavaloader
blob812ac84f2ac170d5fe7cb59c4b7c2acfffb6313c
1 # -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
2 # ex: ts=8 sw=8 noet filetype=sh
4 # bjavaloader(1) completion by Ryan Li <ryan@ryanium.com>
6 have bjavaloader &&
7 _bjavaloader()
9         local cur prev
10         local cmd
11         declare -i cmd
13         COMREPLY=()
14         cur=`_get_cword`
15         prev=${COMP_WORDS[COMP_CWORD-1]}
17         cmd=0
19         for (( i = 0; i < COMP_CWORD; ++i )); do
20                 case ${COMP_WORDS[$i]} in
21                 @(dir|deviceinfo|load|wipe|save|erase| \
22                         eventlog|cleareventlog|logstacktraces|screenshot|settime))
23                         cmd=1
24                         ;;
25                 esac
26         done
28         if [[ "$cur" == -* ]]; then
29                 if [[ $cmd -eq 0 ]]; then
30                         COMPREPLY=( $( compgen -W '-h -p -P -v' -- "$cur" ) )
31                 else
32                 case "$prev" in
33                 dir)
34                         COMPREPLY=( $( compgen -W '-s' -- "$cur" ) )
35                         return 0
36                         ;;
37                 wipe)
38                         COMPREPLY=( $( compgen -W '-a -i' -- "$cur" ) )
39                         return 0
40                         ;;
41                 erase)
42                         COMPREPLY=( $( compgen -W '-f' -- "$cur" ) )
43                         return 0
44                         ;;
45                 *)
46                         ;;
47                 esac
48                 fi
49         elif [[ $cmd -eq 0 ]]; then
50                 COMPREPLY=( $( compgen -W 'dir deviceinfo \
51                         load wipe save erase eventlog cleareventlog \
52                         logstacktraces screenshot settime' -- "$cur" ) )
53         fi
54         case "$prev" in
55         -p)
56                 COMPREPLY=( $( compgen -W \
57                         '$( bidentify 2>&- | sed -e "s/,.*$//" )' \
58                         -- "$cur" ) )
59                 return 0
60                 ;;
61         load)
62                 _filedir cod
63                 return 0
64                 ;;
65         screenshot)
66                 _filedir bmp
67                 return 0
68                 ;;
69         *)
70                 ;;
71         esac
72 } &&
73 complete -F _bjavaloader bjavaloader