From dea48ff7bc9189d4352adf74f7b2783c323c636f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 6 Dec 2022 18:58:58 +0200 Subject: [PATCH 1/2] feat(reportbug): parse various option args from option help Closes https://github.com/scop/bash-completion/pull/753 --- completions/reportbug | 34 ++++++---------------------------- test/t/test_reportbug.py | 4 ++++ 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/completions/reportbug b/completions/reportbug index dad53e6a63a..d29f74a7ce6 100644 --- a/completions/reportbug +++ b/completions/reportbug @@ -27,9 +27,12 @@ _reportbug() done)' -- "$cur")) return ;; - --bts | -!(-*)B) - COMPREPLY=($(compgen -W "debian guug kde mandrake help" -- \ - "$cur")) + --tag | --ui | --interface | --type | --bts | --severity | --mode | -!(-*)[TutBS]) + COMPREPLY+=($( + compgen -W \ + '$("$1" $prev help 2>&1 | sed -ne /^[[:space:]]/p)' \ + -- "$cur" + )) return ;; --editor | --mua | --mbox-reader-cmd | -!(-*)e) @@ -37,31 +40,6 @@ _reportbug() COMPREPLY=($(compgen -c -- "$cur")) return ;; - --mode) - COMPREPLY=($(compgen -W "novice standard expert" -- "$cur")) - return - ;; - --severity | -!(-*)S) - COMPREPLY=($(compgen -W "grave serious important normal minor - wishlist" -- "$cur")) - return - ;; - --ui | --interface | -!(-*)u) - COMPREPLY=($(compgen -W "newt text gnome" -- "$cur")) - return - ;; - --type | -!(-*)t) - COMPREPLY=($(compgen -W "gnats debbugs" -- "$cur")) - return - ;; - --tag | -!(-*)T) - COMPREPLY=($(compgen -W "none woody potato sarge sarge-ignore - etch etch-ignore lenny lenny-ignore sid experimental confirmed - d-i fixed fixed-in-experimental fixed-upstream help l10n - moreinfo patch pending security unreproducible upstream wontfix - ipv6 lfs" -- "$cur")) - return - ;; --from-buildd) COMPREPLY=($(compgen -S "_" -W '$(apt-cache dumpavail | \ command grep "^Source: $cur" | sort -u | cut -f2 -d" ")')) diff --git a/test/t/test_reportbug.py b/test/t/test_reportbug.py index 2c57b56ded1..9347adfbb52 100644 --- a/test/t/test_reportbug.py +++ b/test/t/test_reportbug.py @@ -5,3 +5,7 @@ class TestReportbug: @pytest.mark.complete("reportbug --m", require_cmd=True) def test_1(self, completion): assert completion + + @pytest.mark.complete("reportbug --bts=", require_cmd=True) + def test_bts(self, completion): + assert "default" in completion From 3f9970daf5c84878cd67576268888cd7d82d14fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 18 Dec 2022 18:02:17 +0200 Subject: [PATCH 2/2] fix(reportbug): avoid interactive mode on help, quote sed pattern Co-authored-by: Koichi Murase --- completions/reportbug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completions/reportbug b/completions/reportbug index d29f74a7ce6..8f87cfd9275 100644 --- a/completions/reportbug +++ b/completions/reportbug @@ -30,7 +30,7 @@ _reportbug() --tag | --ui | --interface | --type | --bts | --severity | --mode | -!(-*)[TutBS]) COMPREPLY+=($( compgen -W \ - '$("$1" $prev help 2>&1 | sed -ne /^[[:space:]]/p)' \ + '$("$1" $prev help 2>&1