File click82.patch of Package python-click-repl

Index: click-repl-0.3.0/click_repl/_repl.py
===================================================================
--- click-repl-0.3.0.orig/click_repl/_repl.py
+++ click-repl-0.3.0/click_repl/_repl.py
@@ -129,12 +129,12 @@ def repl(
 
         try:
             # The group command will dispatch based on args.
-            old_protected_args = group_ctx.protected_args
+            old_args = group_ctx.args
             try:
-                group_ctx.protected_args = args
+                group_ctx.args = args
                 group.invoke(group_ctx)
             finally:
-                group_ctx.protected_args = old_protected_args
+                group_ctx.args = old_args
         except click.ClickException as e:
             e.show()
         except (ClickExit, SystemExit):
Index: click-repl-0.3.0/click_repl/utils.py
===================================================================
--- click-repl-0.3.0.orig/click_repl/utils.py
+++ click-repl-0.3.0/click_repl/utils.py
@@ -41,7 +41,7 @@ def _resolve_context(args, ctx=None):
     while args:
         command = ctx.command
 
-        if isinstance(command, click.MultiCommand):
+        if isinstance(command, click.Group) or isinstance(command, click.Command):
             if not command.chain:
                 name, cmd, args = command.resolve_command(ctx, args)
 
@@ -49,7 +49,7 @@ def _resolve_context(args, ctx=None):
                     return ctx
 
                 ctx = cmd.make_context(name, args, parent=ctx, resilient_parsing=True)
-                args = ctx.protected_args + ctx.args
+                args = ctx.args
             else:
                 while args:
                     name, cmd, args = command.resolve_command(ctx, args)
@@ -68,7 +68,7 @@ def _resolve_context(args, ctx=None):
                     args = sub_ctx.args
 
                 ctx = sub_ctx
-                args = [*sub_ctx.protected_args, *sub_ctx.args]
+                args = sub_ctx.args
         else:
             break
 
Index: click-repl-0.3.0/tests/test_basic.py
===================================================================
--- click-repl-0.3.0.orig/tests/test_basic.py
+++ click-repl-0.3.0/tests/test_basic.py
@@ -18,7 +18,7 @@ def test_arg_completion():
     def arg_cmd(handler):
         pass
 
-    completions = list(c.get_completions(Document("arg-cmd ")))
+    completions = list(c.get_completions(Document("arg ")))
     assert {x.text for x in completions} == {"foo", "bar"}
 
 
@@ -31,9 +31,9 @@ def option_cmd(handler):
 @pytest.mark.parametrize(
     "test_input,expected",
     [
-        ("option-cmd ", {"--handler", "-h"}),
-        ("option-cmd -h", {"-h"}),
-        ("option-cmd --h", {"--handler"}),
+        ("option ", {"--handler", "-h"}),
+        ("option -h", {"-h"}),
+        ("option --h", {"--handler"}),
     ],
 )
 def test_option_completion(test_input, expected):
Index: click-repl-0.3.0/tests/test_completion/test_common_tests/test_hidden_cmd_and_args.py
===================================================================
--- click-repl-0.3.0.orig/tests/test_completion/test_common_tests/test_hidden_cmd_and_args.py
+++ click-repl-0.3.0/tests/test_completion/test_common_tests/test_hidden_cmd_and_args.py
@@ -27,7 +27,7 @@ def test_hidden_option():
     def hidden_option_cmd(handler):
         pass
 
-    completions = list(c.get_completions(Document("hidden-option-cmd ")))
+    completions = list(c.get_completions(Document("hidden-option ")))
     assert {x.text for x in completions} == set()
 
 
@@ -41,11 +41,11 @@ def test_args_of_hidden_command():
     completions = list(c.get_completions(Document("option-")))
     assert {x.text for x in completions} == set()
 
-    completions = list(c.get_completions(Document("args-choices-hidden-cmd foo ")))
+    completions = list(c.get_completions(Document("args-choices-hidden foo ")))
     assert {x.text for x in completions} == set()
 
     completions = list(
-        c.get_completions(Document("args-choices-hidden-cmd --handler "))
+        c.get_completions(Document("args-choices-hidden --handler "))
     )
     assert {x.text for x in completions} == set()
 
Index: click-repl-0.3.0/tests/test_command_collection.py
===================================================================
--- click-repl-0.3.0.orig/tests/test_command_collection.py
+++ click-repl-0.3.0/tests/test_command_collection.py
@@ -25,7 +25,7 @@ def test_command_collection():
     c = ClickCompleter(cmd, click.Context(cmd))
     completions = list(c.get_completions(Document("foo")))
 
-    assert {x.text for x in completions} == {"foo-cmd", "foobar-cmd"}
+    assert {x.text for x in completions} == {"foo", "foobar"}
 
 
 @click.group(invoke_without_command=True)
Index: click-repl-0.3.0/click_repl/_completer.py
===================================================================
--- click-repl-0.3.0.orig/click_repl/_completer.py
+++ click-repl-0.3.0/click_repl/_completer.py
@@ -267,7 +267,7 @@ class ClickCompleter(Completer):
                 )
             )
 
-            if isinstance(self.ctx_command, click.MultiCommand):
+            if isinstance(self.ctx_command, click.Group) or isinstance(self.ctx_command, click.Command):
                 incomplete_lower = incomplete.lower()
 
                 for name in self.ctx_command.list_commands(self.parsed_ctx):
openSUSE Build Service is sponsored by