2012-06-16 08:30:10 +08:00
|
|
|
function __fish_complete_wvdial_peers --description 'Complete wvdial peers' --argument cfgfiles
|
2016-11-28 13:27:22 +08:00
|
|
|
set -q cfgfiles[0]
|
|
|
|
or set -l cfgfiles /etc/wvdial.conf ~/.wvdialrc
|
2012-06-16 08:30:10 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
# test if there is an alternative config file specified
|
|
|
|
set -l store_next
|
|
|
|
for opt in (commandline -cpo)
|
|
|
|
if set -q store_next[1]
|
|
|
|
set store_next
|
|
|
|
set cfgfiles $opt
|
|
|
|
continue
|
|
|
|
end
|
2012-06-16 08:30:10 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
switch $opt
|
|
|
|
case -C --config
|
|
|
|
set store_next true
|
|
|
|
case '--config=*'
|
|
|
|
set cfgfiles (echo $opt | string replace '--config=' '')
|
|
|
|
end
|
|
|
|
end
|
2012-06-16 08:30:10 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
for file in $cfgfiles
|
2012-06-16 08:30:10 +08:00
|
|
|
if test -f $file
|
2016-11-28 13:27:22 +08:00
|
|
|
string match -r '\[Dialer' <$file | string replace -r '\[Dialer (.+)\]' '$1'
|
2012-06-16 08:30:10 +08:00
|
|
|
end
|
2016-11-28 13:27:22 +08:00
|
|
|
end | sort -u | string match -v Defaults
|
2012-06-16 08:30:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
end
|