# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo $@ | sed 's/ .*//g');
# get options between "vehicle type " and closing ")", remove line return, remove spaces, anything before the opening (, remove the "|" and closing ")"
opts=$($caller --help | sed -n '/vehicle type (/,/)/p' | tr '\n' ' ' | sed -e 's/ //g' -e 's/.*(//g' -e 's/[|)]/ /g')
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
-f | --frame)
opts=""
if [[ ${COMP_WORDS[@]} == *"ArduCopter"* ]]; then
opts+=" +"
opts+=" X"
opts+=" airsim-copter"
opts+=" coaxcopter"
opts+=" djix"
opts+=" dodeca-hexa"
opts+=" gazebo-iris"
opts+=" heli"
opts+=" heli-compound"
opts+=" heli-dual"
opts+=" hexa"
opts+=" octa"
opts+=" octa-quad"
opts+=" quad"
opts+=" scrimmage-copter"
opts+=" singlecopter"
opts+=" tri"
opts+=" y6"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [[ ${COMP_WORDS[@]} == *"AntennaTracker"* ]]; then
opts+=" tracker"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [[ ${COMP_WORDS[@]} == *"APMrover2"* ]]; then
opts+=" balancebot"
opts+=" gazebo-rover"
opts+=" rover"
opts+=" rover-skid"
opts+=" sailboat"
opts+=" sailboat-motor"
opts+=" balancebot"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [[ ${COMP_WORDS[@]} == *"ArduSub"* ]]; then
opts+=" gazebo-bluerov2"
opts+=" vectored"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [[ ${COMP_WORDS[@]} == *"ArduPlane"* ]]; then
opts+=" CRRCSim"
opts+=" gazebo-zephyr"
opts+=" jsbsim"
opts+=" plane"
opts+=" plane-dspoilers"
opts+=" plane-elevon"
opts+=" plane-jet"
opts+=" plane-tailsitter"
opts+=" plane-vtailjet"
opts+=" quadplane"
opts+=" quadplane-cl84"
opts+=" quadplane-tilttrivec"
opts+=" quadplane-tri"
opts+=" scrimmage-plane"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo $@ | sed 's/ .*//g');
# Get everything between "frame type" and "-C", remove first and last line, get line starting with caracters and ": " sequence, remove spaces and :
local supported_vehicle_list=$($caller --help | sed -n '/frame type/,/-C/p' | sed -e '1d' -e '$d' | sed -n 's/\(.*: \).*/\1/p' | sed -e 's/ //g' -e 's/://g')
local frames;
local count=1;
for v in $supported_vehicle_list
do
if [[ ${COMP_WORDS[@]} == *"$v"* ]]
then
# Get everything between "frame type" and "-C", remove first and last line and change starting space by " :", change newlines to space, remove spaces then change vehicle type enclose by ":" by newline and change "|" by space, remove first line, get line "count" that match supported_vehicle_list[count]
frames=$($caller --help | sed -n '/frame type/,/-C/p' | sed -e '1d' -e '$d' -e 's/^\s*A/ :A/g' | tr '\n' ' ' | sed -e 's/ //g' -e 's/:\w*:/\n/g' -e 's/[|]/ /g' | sed '1d' | sed "${count}q;d")
# TODO : generate with regex from sim_vehicle help
_get_vehicle_type() {
# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo ${words[@]} | sed 's/ .*//g');
# get options between "vehicle type " and closing ")", remove line return, remove spaces, anything before the opening (, remove the "|" and closing ")"
vehicles=( $($caller --help | sed -n '/vehicle type (/,/)/p' | tr '\n' ' ' | sed -e 's/ //g' -e 's/.*(//g' -e 's/[|)]/ /g') )
'quadplane-tilttrivec:Plane type quadplane-tilttrivec' \
'quadplane-tri:Plane type quadplane-tri' \
'scrimmage-plane:Plane for scrimmage' \
);;
esac
# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo ${words[@]} | sed 's/ .*//g');
# to get the vehicle list :
# Get everything between "frame type" and "-C", remove first and last line, get line starting with caracters and ": " sequence, remove spaces and :
local supported_vehicle_list=($($caller --help | sed -n '/frame type/,/-C/p' | sed -e '1d' -e '$d' | sed -n 's/\(.*: \).*/\1/p' | sed -e 's/ //g' -e 's/://g'))
local frames;
local count=1;
for v in $supported_vehicle_list
do
if [ "$v" = "$vehicle" ]
then
# Get everything between "frame type" and "-C", remove first and last line and change starting space by " :", change newlines to space, remove spaces then change vehicle type enclose by ":" by newline and change "|" by space, remove first line, get line "count" that match supported_vehicle_list[count]
frames=($($caller --help | sed -n '/frame type/,/-C/p' | sed -e '1d' -e '$d' -e 's/^\s*A/ :A/g' | tr '\n' ' ' | sed -e 's/ //g' -e 's/:\w*:/\n/g' -e 's/[|]/ /g' | sed '1d' | sed "${count}q;d"))