Ayaka Koshibe
Committed by Yuta Higuchi

vicell command for editing/applying cell configurations

Change-Id: I3e9731342ef015649978941ba984af4fc0af41d2
...@@ -116,3 +116,41 @@ function spy { ...@@ -116,3 +116,41 @@ function spy {
116 function nuke { 116 function nuke {
117 spy "$@" | cut -c7-11 | xargs kill 117 spy "$@" | cut -c7-11 | xargs kill
118 } 118 }
119 +
120 +# Edit a cell file by providing a cell name. Opens the cell file in $EDITOR.
121 +function vicell() {
122 + local apply=false
123 + local create=false
124 + local cdf=""
125 + local cpath="${ONOS_ROOT}/tools/test/cells/"
126 +
127 + if [ -z "$1" ] || [ "$1" = "-h" ] ; then
128 + printf "usage: vicell [file] [options]\n\noptions:\n"
129 + printf "\t-a: apply the cell after editing\n"
130 + printf "\t-e: [editor] set EDITOR to [editor] (default *vi*)\n"
131 + printf "\t-c: create cell file if none exist\n\n"
132 + return 1
133 + fi
134 +
135 + while [ $# -gt 0 ]; do
136 + case "$1" in
137 + -a) apply=true ;;
138 + -e) EDITOR=$2; shift ;;
139 + -c) create=true ;;
140 + *) cdf="$1" ;;
141 + esac
142 + shift
143 + done
144 +
145 + if [ ! -e "${cpath}${cdf}" ] && [ "$create" = "false" ]; then
146 + printf "${cdf} : no such cell\n" && return 1
147 + fi
148 +
149 + if [ -z "$EDITOR" ]; then
150 + vi ${cpath}${cdf}
151 + else
152 + $EDITOR ${cpath}${cdf}
153 + fi
154 + ($apply) && cell ${cdf}
155 +
156 +}
......