mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
Tools: completion bash: fix and simplify frames completion
This commit is contained in:
parent
ad7f62b23d
commit
7292ee8ec6
@ -65,7 +65,7 @@ _sim_vehicle() {
|
|||||||
# get the calling program, remove anything after the space == all commands arguments
|
# get the calling program, remove anything after the space == all commands arguments
|
||||||
local caller; caller=$(echo $@ | sed 's/ .*//g');
|
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 ")"
|
# 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' | sed -e '1d' | tr -d '()' | tr '\n' ' ' | sed -e 's/ //g' -e 's/.*(//g' -e 's/[|)]/ /g')
|
opts=$($caller --list-vehicle)
|
||||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
@ -75,16 +75,13 @@ _sim_vehicle() {
|
|||||||
# Get everything between "frame type" and "-C", remove first and last line, get line starting with caracters and ": " sequence, remove spaces and :
|
# 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 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 frames;
|
||||||
local count=1;
|
|
||||||
for v in $supported_vehicle_list
|
for v in $supported_vehicle_list
|
||||||
do
|
do
|
||||||
if [[ ${COMP_WORDS[@]} == *"$v"* ]]
|
if [[ ${COMP_WORDS[@]} == *"$v"* ]]
|
||||||
then
|
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 --list-frame "$v")
|
||||||
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")
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
count=$(( $count + 1 ))
|
|
||||||
done
|
done
|
||||||
COMPREPLY=($(compgen -W "${frames}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${frames}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user