From f871951a87e3b19568fbd4f77dcfc004eabd5e8d Mon Sep 17 00:00:00 2001 From: Curtis Jiang Date: Mon, 31 Dec 2018 23:48:03 +0800 Subject: [PATCH] fix OpenWrt and opkg support (#5454) * add OpenWrt and opkg support Signed-off-by: Curtis Jiang * fix opkg list Signed-off-by: Curtis Jiang --- share/completions/opkg.fish | 37 ++++++++++++++-------- share/functions/__fish_print_packages.fish | 2 +- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/share/completions/opkg.fish b/share/completions/opkg.fish index 9654be418..9e11bb92d 100644 --- a/share/completions/opkg.fish +++ b/share/completions/opkg.fish @@ -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.' \ No newline at end of file +complete -c opkg -s l -l lists-dir -d 'Specify lists-dir.' diff --git a/share/functions/__fish_print_packages.fish b/share/functions/__fish_print_packages.fish index 413c674c3..09e162460 100644 --- a/share/functions/__fish_print_packages.fish +++ b/share/functions/__fish_print_packages.fish @@ -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