Skip to content

Commit

Permalink
Bug #52514: Patches the wrong usage of configure through text replace…
Browse files Browse the repository at this point in the history
…ment

  This was done with text replacement, because this is a bug from argparse
  and it was not fixed in the last 10 years. python/cpython#53584
  • Loading branch information
Polyfish0 committed Nov 24, 2022
1 parent e993b1c commit dcdbd64
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#

from tempfile import NamedTemporaryFile
from argparse import SUPPRESS
from argparse import SUPPRESS, HelpFormatter

from univention.appcenter.actions import UniventionAppAction, StoreAppAction
from univention.appcenter.exceptions import ConfigureFailed
Expand All @@ -52,6 +52,7 @@ class Configure(UniventionAppAction):
help = 'Configure an app'

def setup_parser(self, parser):
parser.formatter_class = PatchedHelpFormatter
parser.add_argument('app', action=StoreAppAction, help='The ID of the App that shall be configured')
parser.add_argument('--list', action='store_true', help='List all configuration options as well as their current values')
parser.add_argument('--set', nargs='+', action=StoreConfigAction, metavar='KEY=VALUE', dest='set_vars', help='Sets the configuration variable. Example: --set some/variable=value some/other/variable="value 2"')
Expand Down Expand Up @@ -135,3 +136,10 @@ def _run_configure_script(self, app, action):
for line in error_file:
self.fatal(line)
return success


class PatchedHelpFormatter(HelpFormatter):
def _format_usage(self, *args, **kwargs):
usage = super()._format_usage(*args, **kwargs)

return usage.replace(' app\n\n', ' ').replace('[-h]', '[-h] app').rstrip()

0 comments on commit dcdbd64

Please sign in to comment.