55import os
66from typing import List , Optional
77
8- from click import Command , Context , MultiCommand , style
8+ from click import Command , Context , Group , style
99
1010from samcli .cli .row_modifiers import RowDefinition
1111from samcli .commands .docs .command_context import COMMAND_NAME , DocsCommandContext
@@ -90,19 +90,19 @@ def format_options(self, ctx: Context, formatter: DocsCommandHelpTextFormatter):
9090 self .format_sub_commands (formatter )
9191
9292
93- class DocsSubCommand (MultiCommand ):
94- def __init__ (self , command : Optional [List [str ]] = None , * args , ** kwargs ):
93+ class DocsSubCommand (Group ):
94+ def __init__ (self , command_list : Optional [List [str ]] = None , * args , ** kwargs ):
9595 """
9696 Constructor for instantiating a sub-command for the docs command
9797
9898 Parameters
9999 ----------
100- command : Optional[List[str]]
100+ command_list : Optional[List[str]]
101101 Optional list of strings representing the fully resolved command name (e.g. ["docs", "local", "invoke"])
102102 """
103103 super ().__init__ (* args , ** kwargs )
104104 self .docs_command = DocsCommandContext ()
105- self .command = command or self .docs_command .sub_commands
105+ self .command_list = command_list or self .docs_command .sub_commands . copy ()
106106 self .command_string = self .docs_command .sub_command_string
107107 self .command_callback = self .docs_command .command_callback
108108
@@ -127,14 +127,19 @@ def get_command(self, ctx: Context, cmd_name: str) -> Command:
127127 or the leaf command to be invoked by the command handler
128128
129129 """
130- next_command = self .command .pop (0 )
131- if not self .command :
130+ if not self .command_list :
131+ return None # type: ignore # This is expected by Click's interface
132+
133+ next_command = self .command_list [0 ]
134+ remaining_commands = self .command_list [1 :] if len (self .command_list ) > 1 else []
135+
136+ if not remaining_commands :
132137 return DocsBaseCommand (
133138 name = next_command ,
134139 short_help = f"Documentation for { self .command_string } " ,
135140 callback = self .command_callback ,
136141 )
137- return DocsSubCommand (command = self . command )
142+ return DocsSubCommand (command_list = remaining_commands )
138143
139144 def list_commands (self , ctx : Context ) -> List [str ]:
140145 """
0 commit comments