|
3 | 3 | importos |
4 | 4 | importre |
5 | 5 | importsys |
| 6 | +importtextwrap |
6 | 7 | fromtypesimportModuleType |
7 | 8 | fromtypingimport ( |
8 | 9 | Any, |
@@ -50,11 +51,20 @@ def format_help(self) -> str: |
50 | 51 | forlineinresult.splitlines(keepends=True): |
51 | 52 | # All of our resources are on one line and wrapped inside braces. |
52 | 53 | # For example: {application,resource1,resource2} |
| 54 | +# except if there are fewer resources - then the line and help text |
| 55 | +# are collapsed on the same line. |
| 56 | +# For example: {list} Action to execute on the GitLab resource. |
53 | 57 | # We then put each resource on its own line to make it easier to read. |
54 | 58 | ifline.strip().startswith("{"): |
55 | | -choices=line.strip().strip("{}").split(",") |
56 | | -choices_str=f"\n{indent}".join(choices) |
57 | | -line=f"{indent}{choices_str}\n" |
| 59 | +choice_string,help_string=line.split("}",1) |
| 60 | +choice_list=choice_string.strip(" {").split(",") |
| 61 | + |
| 62 | +ifhelp_string.strip(): |
| 63 | +help_indent=len(max(choice_list,key=len))*" " |
| 64 | +choice_list.append(f"{help_indent}{help_string}") |
| 65 | + |
| 66 | +choices="\n".join(choice_list) |
| 67 | +line=f"{textwrap.indent(choices,indent)}\n" |
58 | 68 | output+=line |
59 | 69 | returnoutput |
60 | 70 |
|
|