mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-14 17:46:17 +01:00
Move osc specific bits to commandline module.
This commit is contained in:
parent
7f173ab244
commit
e5563bcaa4
50
osc/cmdln.py
50
osc/cmdln.py
@ -43,7 +43,6 @@ import re
|
|||||||
import cmd
|
import cmd
|
||||||
import optparse
|
import optparse
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from core import get_osc_version
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
|
|
||||||
@ -62,17 +61,17 @@ _NOT_SPECIFIED = ("Not", "Specified")
|
|||||||
_INCORRECT_NUM_ARGS_RE = re.compile(
|
_INCORRECT_NUM_ARGS_RE = re.compile(
|
||||||
r"(takes [\w ]+ )(\d+)( arguments? \()(\d+)( given\))")
|
r"(takes [\w ]+ )(\d+)( arguments? \()(\d+)( given\))")
|
||||||
|
|
||||||
MAN_HEADER = r""".TH OSC "1" "%s" "osc %s" "User Commands"
|
# Static bits of man page
|
||||||
|
MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
osc \- OpenSUSE build service command-line tool.
|
%(name)s \- Program to do useful things.
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B osc
|
.B %(name)s
|
||||||
[\fIGLOBALOPTS\fR] \fISUBCOMMAND \fR[\fIOPTS\fR] [\fIARGS\fR...]
|
[\fIGLOBALOPTS\fR] \fISUBCOMMAND \fR[\fIOPTS\fR] [\fIARGS\fR...]
|
||||||
.br
|
.br
|
||||||
.B osc
|
.B %(name)s
|
||||||
\fIhelp SUBCOMMAND\fR
|
\fIhelp SUBCOMMAND\fR
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
OpenSUSE build service command\-line tool.
|
|
||||||
"""
|
"""
|
||||||
MAN_COMMANDS_HEADER = r"""
|
MAN_COMMANDS_HEADER = r"""
|
||||||
.SS COMMANDS
|
.SS COMMANDS
|
||||||
@ -81,17 +80,8 @@ MAN_OPTIONS_HEADER = r"""
|
|||||||
.SS GLOBAL OPTIONS
|
.SS GLOBAL OPTIONS
|
||||||
"""
|
"""
|
||||||
MAN_FOOTER = r"""
|
MAN_FOOTER = r"""
|
||||||
.SH "SEE ALSO"
|
|
||||||
Type 'osc help <subcommand>' for more detailed help on a specific subcommand.
|
|
||||||
.PP
|
|
||||||
For additional information, see
|
|
||||||
* http://www.opensuse.org/Build_Service_Tutorial
|
|
||||||
* http://www.opensuse.org/Build_Service/CLI
|
|
||||||
.PP
|
|
||||||
You can modify osc commands, or roll you own, via the plugin API:
|
|
||||||
* http://www.opensuse.org/Build_Service/osc_plugins
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
osc was written by several authors. This man page is automatically generated.
|
This man page is automatically generated.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#---- exceptions
|
#---- exceptions
|
||||||
@ -162,6 +152,12 @@ class RawCmdln(cmd.Cmd):
|
|||||||
|
|
||||||
helpindent = '' # string with which to indent help output
|
helpindent = '' # string with which to indent help output
|
||||||
|
|
||||||
|
# Default man page parts, please change them in subclass
|
||||||
|
man_header = MAN_HEADER
|
||||||
|
man_commands_header = MAN_COMMANDS_HEADER
|
||||||
|
man_options_header = MAN_OPTIONS_HEADER
|
||||||
|
man_footer = MAN_FOOTER
|
||||||
|
|
||||||
def __init__(self, completekey='tab',
|
def __init__(self, completekey='tab',
|
||||||
stdin=None, stdout=None, stderr=None):
|
stdin=None, stdout=None, stderr=None):
|
||||||
"""Cmdln(completekey='tab', stdin=None, stdout=None, stderr=None)
|
"""Cmdln(completekey='tab', stdin=None, stdout=None, stderr=None)
|
||||||
@ -220,6 +216,12 @@ class RawCmdln(cmd.Cmd):
|
|||||||
or None)
|
or None)
|
||||||
return CmdlnOptionParser(self, version=version)
|
return CmdlnOptionParser(self, version=version)
|
||||||
|
|
||||||
|
def get_version(self):
|
||||||
|
"""
|
||||||
|
Returns version of program. To be replaced in subclass.
|
||||||
|
"""
|
||||||
|
return __version__
|
||||||
|
|
||||||
def postoptparse(self):
|
def postoptparse(self):
|
||||||
"""Hook method executed just after `.main()' parses top-level
|
"""Hook method executed just after `.main()' parses top-level
|
||||||
options.
|
options.
|
||||||
@ -542,11 +544,15 @@ class RawCmdln(cmd.Cmd):
|
|||||||
usage:
|
usage:
|
||||||
${name} man
|
${name} man
|
||||||
"""
|
"""
|
||||||
self.stdout.write(MAN_HEADER % (
|
self.stdout.write(self.man_header % {
|
||||||
date.today().strftime('%b %Y'),
|
'date': date.today().strftime('%b %Y'),
|
||||||
get_osc_version()))
|
'version': self.get_version(),
|
||||||
|
'name': self.name,
|
||||||
|
'ucname': self.name.upper()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self.stdout.write(MAN_COMMANDS_HEADER)
|
self.stdout.write(self.man_commands_header)
|
||||||
commands = self._help_get_command_list()
|
commands = self._help_get_command_list()
|
||||||
for command, doc in commands:
|
for command, doc in commands:
|
||||||
cmdname = command.split(' ')[0]
|
cmdname = command.split(' ')[0]
|
||||||
@ -559,10 +565,10 @@ class RawCmdln(cmd.Cmd):
|
|||||||
|
|
||||||
self.stdout.write('.TP\n\\fB%s\\fR\n%s\n' % (command, '\n'.join(lines)))
|
self.stdout.write('.TP\n\\fB%s\\fR\n%s\n' % (command, '\n'.join(lines)))
|
||||||
|
|
||||||
self.stdout.write(MAN_OPTIONS_HEADER)
|
self.stdout.write(self.man_options_header)
|
||||||
self.stdout.write(self._help_preprocess('${option_list}', None))
|
self.stdout.write(self._help_preprocess('${option_list}', None))
|
||||||
|
|
||||||
self.stdout.write(MAN_FOOTER)
|
self.stdout.write(self.man_footer)
|
||||||
|
|
||||||
self.stdout.flush()
|
self.stdout.flush()
|
||||||
|
|
||||||
|
@ -11,6 +11,32 @@ import cmdln
|
|||||||
import conf
|
import conf
|
||||||
import oscerr
|
import oscerr
|
||||||
|
|
||||||
|
MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands"
|
||||||
|
.SH NAME
|
||||||
|
%(name)s \- OpenSUSE build service command-line tool.
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B %(name)s
|
||||||
|
[\fIGLOBALOPTS\fR] \fISUBCOMMAND \fR[\fIOPTS\fR] [\fIARGS\fR...]
|
||||||
|
.br
|
||||||
|
.B %(name)s
|
||||||
|
\fIhelp SUBCOMMAND\fR
|
||||||
|
.SH DESCRIPTION
|
||||||
|
OpenSUSE build service command\-line tool.
|
||||||
|
"""
|
||||||
|
MAN_FOOTER = r"""
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
Type 'osc help <subcommand>' for more detailed help on a specific subcommand.
|
||||||
|
.PP
|
||||||
|
For additional information, see
|
||||||
|
* http://www.opensuse.org/Build_Service_Tutorial
|
||||||
|
* http://www.opensuse.org/Build_Service/CLI
|
||||||
|
.PP
|
||||||
|
You can modify osc commands, or roll you own, via the plugin API:
|
||||||
|
* http://www.opensuse.org/Build_Service/osc_plugins
|
||||||
|
.SH AUTHOR
|
||||||
|
osc was written by several authors. This man page is automatically generated.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Osc(cmdln.Cmdln):
|
class Osc(cmdln.Cmdln):
|
||||||
"""Usage: osc [GLOBALOPTS] SUBCOMMAND [OPTS] [ARGS...]
|
"""Usage: osc [GLOBALOPTS] SUBCOMMAND [OPTS] [ARGS...]
|
||||||
@ -32,11 +58,15 @@ class Osc(cmdln.Cmdln):
|
|||||||
name = 'osc'
|
name = 'osc'
|
||||||
conf = None
|
conf = None
|
||||||
|
|
||||||
|
man_header = MAN_HEADER
|
||||||
|
man_footer = MAN_FOOTER
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
cmdln.Cmdln.__init__(self, *args, **kwargs)
|
cmdln.Cmdln.__init__(self, *args, **kwargs)
|
||||||
cmdln.Cmdln.do_help.aliases.append('h')
|
cmdln.Cmdln.do_help.aliases.append('h')
|
||||||
|
|
||||||
|
def get_version(self):
|
||||||
|
return get_osc_version()
|
||||||
|
|
||||||
def get_optparser(self):
|
def get_optparser(self):
|
||||||
"""this is the parser for "global" options (not specific to subcommand)"""
|
"""this is the parser for "global" options (not specific to subcommand)"""
|
||||||
|
Loading…
Reference in New Issue
Block a user