mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 17:16:23 +01:00
Add proper escaping of - in man page.
This commit is contained in:
parent
2af8cbbf7e
commit
a574dbb3aa
22
osc/cmdln.py
22
osc/cmdln.py
@ -117,6 +117,24 @@ def alias(*aliases):
|
||||
return f
|
||||
return decorate
|
||||
|
||||
MAN_REPLACES = [
|
||||
(re.compile(r'(^|[ \t])--([^/ \t-]*)-([^/ \t-]*)-([^/ \t-]*)($|[ \t=])'), r'\1\-\-\2\-\3\-\4\5'),
|
||||
(re.compile(r'(^|[ \t])-([^/ \t-]*)-([^/ \t-]*)-([^/ \t-]*)($|[ \t=])'), r'\1\-\2\-\3\-\4\5'),
|
||||
(re.compile(r'(^|[ \t])--([^/ \t-]*)-([^/ \t-]*)($|[ \t=])'), r'\1\-\-\2\-\3\4'),
|
||||
(re.compile(r'(^|[ \t])-([^/ \t-]*)-([^/ \t-]*)($|[ \t=])'), r'\1\-\2\-\3\4'),
|
||||
(re.compile(r'(^|[ \t])--([^/ \t-]*)($|[ \t=])'), r'\1\-\-\2\3'),
|
||||
(re.compile(r'(^|[ \t])-([^/ \t-]*)($|[ \t=])'), r'\1\-\2\3'),
|
||||
]
|
||||
|
||||
def man_escape(text):
|
||||
'''
|
||||
Escapes text to be included in man page.
|
||||
|
||||
For now it only escapes dashes in command line options.
|
||||
'''
|
||||
for repl in MAN_REPLACES:
|
||||
text = repl[0].sub(repl[1], text)
|
||||
return text
|
||||
|
||||
class RawCmdln(cmd.Cmd):
|
||||
"""An improved (on cmd.Cmd) framework for building multi-subcommand
|
||||
@ -561,12 +579,12 @@ class RawCmdln(cmd.Cmd):
|
||||
for line in text.splitlines(False):
|
||||
if line[:8] == ' ' * 8:
|
||||
line = line[8:]
|
||||
lines.append(line)
|
||||
lines.append(man_escape(line))
|
||||
|
||||
self.stdout.write('.TP\n\\fB%s\\fR\n%s\n' % (command, '\n'.join(lines)))
|
||||
|
||||
self.stdout.write(self.man_options_header)
|
||||
self.stdout.write(self._help_preprocess('${option_list}', None))
|
||||
self.stdout.write(man_escape(self._help_preprocess('${option_list}', None)))
|
||||
|
||||
self.stdout.write(self.man_footer)
|
||||
|
||||
|
@ -21,7 +21,7 @@ MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Comm
|
||||
.B %(name)s
|
||||
\fIhelp SUBCOMMAND\fR
|
||||
.SH DESCRIPTION
|
||||
OpenSUSE build service command\-line tool.
|
||||
OpenSUSE build service command-line tool.
|
||||
"""
|
||||
MAN_FOOTER = r"""
|
||||
.SH "SEE ALSO"
|
||||
|
Loading…
Reference in New Issue
Block a user