@@ -69,9 +69,10 @@ def process_command(
6969 raise ValueError (f"Failed to get help output for { prefix } " )
7070
7171 subcommands = subcommand if isinstance (subcommand , tuple ) else (subcommand ,)
72+ used_subcommand = subcommands [0 ]
7273
7374 # Construct the regular expression pattern
74- escaped_prefix = re .escape (prefix + (" " + subcommands [ 0 ] ))
75+ escaped_prefix = re .escape (prefix + (" " + used_subcommand ))
7576 # This matches against the command name then until the next command (## `) or the end of the string
7677 pattern = rf"# `{ escaped_prefix } `\n(.*?)(?=\n## `|\Z)"
7778
@@ -95,8 +96,13 @@ def process_command(
9596
9697 first_match : str = matches [0 ]
9798
99+ used_subcommand = (
100+ used_subcommand [: used_subcommand .index ("-" )]
101+ if "-" in used_subcommand
102+ else used_subcommand
103+ )
98104 if not contains_nested_subcommand :
99- cli_to_doc [subcommands [ 0 ] ] = (
105+ cli_to_doc [used_subcommand ] = (
100106 first_match .strip ().replace ("<" , "<" ).replace (">" , ">" )
101107 )
102108 return
@@ -108,7 +114,7 @@ def process_command(
108114 for match in subcommands_matches :
109115 nested_subcommand_name = match .group (1 ).strip ()
110116 command_doc = match .group (2 ).strip ().replace ("<" , "<" ).replace (">" , ">" )
111- cli_to_doc [subcommands [ 0 ] + " " + nested_subcommand_name ] = command_doc
117+ cli_to_doc [used_subcommand + " " + nested_subcommand_name ] = command_doc
112118
113119
114120# List of command prefixes and their corresponding file paths
0 commit comments