1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-12-04 17:34:47 +01:00

Fix rendering help output by adding the complete docstring of the commands

This commit is contained in:
2025-04-03 14:18:13 +02:00
parent e9b65037ef
commit 7a4cf1a8df
3 changed files with 20 additions and 9 deletions

View File

@@ -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

View File

@@ -126,6 +126,7 @@ class Command:
if not help_lines: if not help_lines:
return "" return ""
if getattr(self.main_command, "argparse_manpage", False):
# skip the first line that contains help text # skip the first line that contains help text
help_lines.pop(0) help_lines.pop(0)

View File

@@ -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