mirror of
https://github.com/openSUSE/osc.git
synced 2025-12-04 09:31:11 +01:00
Fix rendering help output by adding the complete docstring of the commands
This commit is contained in:
@@ -280,11 +280,14 @@ class OscMainCommand(MainCommand):
|
|||||||
self.load_command(cls, "osc.commands.old")
|
self.load_command(cls, "osc.commands.old")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def main(cls, argv=None, run=True):
|
def main(cls, argv=None, run=True, argparse_manpage=False):
|
||||||
"""
|
"""
|
||||||
Initialize OscMainCommand, load all commands and run the selected command.
|
Initialize OscMainCommand, load all commands and run the selected command.
|
||||||
"""
|
"""
|
||||||
cmd = cls()
|
cmd = cls()
|
||||||
|
# argparse-manpage splits command's help text to help and description
|
||||||
|
# we normally use both in the --help output, but want to change that for argparse-manpage
|
||||||
|
cmd.argparse_manpage = argparse_manpage
|
||||||
cmd.load_commands()
|
cmd.load_commands()
|
||||||
cmd.load_legacy_commands()
|
cmd.load_legacy_commands()
|
||||||
if run:
|
if run:
|
||||||
@@ -300,7 +303,7 @@ def get_parser():
|
|||||||
"""
|
"""
|
||||||
Needed by argparse-manpage to generate man pages from the argument parser.
|
Needed by argparse-manpage to generate man pages from the argument parser.
|
||||||
"""
|
"""
|
||||||
main, _ = OscMainCommand.main(run=False)
|
main, _ = OscMainCommand.main(run=False, argparse_manpage=True)
|
||||||
return main.parser
|
return main.parser
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -126,13 +126,14 @@ class Command:
|
|||||||
if not help_lines:
|
if not help_lines:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# skip the first line that contains help text
|
if getattr(self.main_command, "argparse_manpage", False):
|
||||||
help_lines.pop(0)
|
# skip the first line that contains help text
|
||||||
|
|
||||||
# remove any leading empty lines
|
|
||||||
while help_lines and not help_lines[0]:
|
|
||||||
help_lines.pop(0)
|
help_lines.pop(0)
|
||||||
|
|
||||||
|
# remove any leading empty lines
|
||||||
|
while help_lines and not help_lines[0]:
|
||||||
|
help_lines.pop(0)
|
||||||
|
|
||||||
result = "\n".join(help_lines)
|
result = "\n".join(help_lines)
|
||||||
result = textwrap.dedent(result)
|
result = textwrap.dedent(result)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ def complete_checkout_pr(prefix, parsed_args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
class GitObsMainCommand(osc.commandline_common.MainCommand):
|
class GitObsMainCommand(osc.commandline_common.MainCommand):
|
||||||
|
"""
|
||||||
|
git-obs is a command-line client for interacting with Git repositories within a Gitea instance that is part of an Open Build Service (OBS).
|
||||||
|
"""
|
||||||
|
|
||||||
name = "git-obs"
|
name = "git-obs"
|
||||||
|
|
||||||
MODULES = (
|
MODULES = (
|
||||||
@@ -198,11 +202,14 @@ class GitObsMainCommand(osc.commandline_common.MainCommand):
|
|||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def main(cls, argv=None, run=True):
|
def main(cls, argv=None, run=True, argparse_manpage=False):
|
||||||
"""
|
"""
|
||||||
Initialize OscMainCommand, load all commands and run the selected command.
|
Initialize OscMainCommand, load all commands and run the selected command.
|
||||||
"""
|
"""
|
||||||
cmd = cls()
|
cmd = cls()
|
||||||
|
# argparse-manpage splits command's help text to help and description
|
||||||
|
# we normally use both in the --help output, but want to change that for argparse-manpage
|
||||||
|
cmd.argparse_manpage = argparse_manpage
|
||||||
cmd.load_commands()
|
cmd.load_commands()
|
||||||
cmd.enable_autocomplete()
|
cmd.enable_autocomplete()
|
||||||
if run:
|
if run:
|
||||||
@@ -253,7 +260,7 @@ def get_parser():
|
|||||||
"""
|
"""
|
||||||
Needed by argparse-manpage to generate man pages from the argument parser.
|
Needed by argparse-manpage to generate man pages from the argument parser.
|
||||||
"""
|
"""
|
||||||
main, _ = GitObsMainCommand.main(run=False)
|
main, _ = GitObsMainCommand.main(run=False, argparse_manpage=True)
|
||||||
return main.parser
|
return main.parser
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user