fix OpenWrt and opkg support (#5454)

* add OpenWrt and opkg support

Signed-off-by: Curtis Jiang <jqqqqqqqqqq@qq.com>

* fix opkg list

Signed-off-by: Curtis Jiang <jqqqqqqqqqq@qq.com>
This commit is contained in:
Curtis Jiang 2018-12-31 23:48:03 +08:00 committed by Fabian Homborg
parent 9b980f5e6e
commit f871951a87
2 changed files with 25 additions and 14 deletions

View File

@ -1,25 +1,36 @@
#completion for opkg
function __fish_opkg_no_subcommand -d 'Test if opkg has yet to be given the subcommand'
for i in (commandline -opc)
if contains -- $i update upgrade install configure remove flag list list-installed list-upgradable list-changed-conffiles files search find info status download compare-versions print-architecture depends whatdepends whatdependsrec whatrecommends whatsuggests whatprovides whatconflicts whatreplaces
return 1
end
end
return 0
for i in (commandline -opc)
if contains -- $i update upgrade install configure remove flag list list-installed list-upgradable list-changed-conffiles files search find info status download compare-versions print-architecture depends whatdepends whatdependsrec whatrecommends whatsuggests whatprovides whatconflicts whatreplaces
return 1
end
end
return 0
end
function __fish_opkg_use_package -d 'Test if opkg command should have packages as potential completion'
for i in (commandline -opc)
if contains -- $i contains upgrade install configure remove flag files search find info status download compare-versions print-architecture depends whatdepends whatdependsrec whatrecommends whatsuggests whatprovides whatconflicts whatreplaces
return 0
end
end
return 1
for i in (commandline -opc)
if contains -- $i contains install search find info status download compare-versions print-architecture depends whatdepends whatdependsrec whatrecommends whatsuggests whatprovides whatconflicts whatreplaces
return 0
end
end
return 1
end
function __fish_opkg_use_package_installed -d 'Test if opkg command should have installed packages as potential completion'
for i in (commandline -opc)
if contains -- $i contains upgrade configure remove flag files
return 0
end
end
return 1
end
complete -c opkg -n '__fish_opkg_use_package' -a '(__fish_print_packages)' -d 'Package'
complete -c opkg -n '__fish_opkg_use_package_installed' -a '(__fish_print_packages --installed)' -d 'Package'
complete -f -n '__fish_opkg_no_subcommand' -c opkg -a 'update' -d 'Update list of available packages'
complete -f -n '__fish_opkg_no_subcommand' -c opkg -a 'upgrade' -d 'Upgrade packages'
complete -f -n '__fish_opkg_no_subcommand' -c opkg -a 'install' -d 'Install package(s)'
@ -73,4 +84,4 @@ complete -c opkg -l size -d 'Print package size when listing available packages'
complete -c opkg -l force-removal-of-dependent-packages -d 'Remove package and all dependencies'
complete -c opkg -l autoremove -d 'Remove automatically installed packages'
complete -c opkg -s t -l tmp-dir -d 'Specify tmp-dir.'
complete -c opkg -s l -l lists-dir -d 'Specify lists-dir.'
complete -c opkg -s l -l lists-dir -d 'Specify lists-dir.'

View File

@ -221,7 +221,7 @@ function __fish_print_packages
end
if type -q -f opkg
if not set -q only_installed
if set -q only_installed
opkg list-installed 2>/dev/null | sed -r 's/^([a-zA-Z0-9\-]+) - ([a-zA-Z0-9\-]+)/\1\t\2/g'
return
else