backend/satellite_tools/spacewalk-report | 35 ++++++++------------------
backend/satellite_tools/spacewalk-report.sgml | 27 +++++---------------
2 files changed, 18 insertions(+), 44 deletions(-)
New commits:
commit 0a3acfa16dc946fc389efcda456e17617d383133
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Thu Nov 19 12:21:54 2009 +0100
537063 - drop the report-specific options, do all in generic options, also allow
options after report name.
To get --list-fields --info behaviour, use --list-fields-info now.
diff --git a/backend/satellite_tools/spacewalk-report
b/backend/satellite_tools/spacewalk-report
index 0143698..cd1be9e 100755
--- a/backend/satellite_tools/spacewalk-report
+++ b/backend/satellite_tools/spacewalk-report
@@ -60,44 +60,31 @@ def processCommandline():
+ ' default is default_db from /etc/rhn/rhn.conf'),
Option('--info', action='store_true',
help='print synopsis of the report in the list of report, or description of
individual reports specified'),
+ Option('--list-fields', action='store_true',
+ dest='listfields',
+ help='list fields of the report instead of running the report'),
+ Option('--list-fields-info', action='store_true',
+ dest='listfieldsinfo',
+ help='as --list-fields but also prints description for each column'),
]
optionParser = OptionParser( \
- usage="usage: %s [options] [report_name [report_options]]" % sys.argv[0], \
+ usage="usage: %s [options] [report_name]" % sys.argv[0], \
option_list=optionsTable)
- optionParser.disable_interspersed_args()
options, args = optionParser.parse_args()
sys.argv[1:] = args
return options
-def processCommandlineReport(report):
- """ process the commandline options for one report """
-
- optionsTable = [
- Option('--list-fields', action='store_true',
- dest='listfields',
- help='list fields of the report instead of running the report'),
- Option('--info', action='store_true',
- help='print description for each column'),
- ]
- optionParserReport = OptionParser(
- usage="options for report %s" % report,
- option_list=optionsTable,
- )
- options, args = optionParserReport.parse_args()
-
- return options
-
-
if __name__ == '__main__':
options = processCommandline()
try:
+ if len(sys.argv) > 2:
+ systemExit(-5, 'Only one report name expected.')
if len(sys.argv) > 1:
report_name = sys.argv[1]
- report_options = processCommandlineReport(report_name)
try:
report = reports.report(report_name)
@@ -115,7 +102,7 @@ if __name__ == '__main__':
print report.description
need_exit = True
- if report_options.listfields:
+ if options.listfields or options.listfieldsinfo:
if options.info:
print
print "Fields in the report:"
@@ -125,7 +112,7 @@ if __name__ == '__main__':
text = c
if options.info:
text = " %s" % c
- if report_options.info and report.column_descriptions.has_key(c) :
+ if options.listfieldsinfo and report.column_descriptions.has_key(c) :
text = "%s: %s" % ( text, report.column_descriptions[c] )
print text
need_exit = True
diff --git a/backend/satellite_tools/spacewalk-report.sgml
b/backend/satellite_tools/spacewalk-report.sgml
index 7ba8d5d..d792336 100644
--- a/backend/satellite_tools/spacewalk-report.sgml
+++ b/backend/satellite_tools/spacewalk-report.sgml
@@ -32,11 +32,9 @@ Generate reports from Spacewalk server in csv format
<sbr />
<arg>--info</arg>
<sbr />
- <arg
choice='plain'><replaceable>report-name</replaceable></arg>
- <sbr />
- <arg>--list-fields <arg>--info</arg></arg>
+
<group><arg>--list-fields</arg><arg>--list-fields-info</arg></group>
<sbr />
- <arg choice='plain'>other report specific options</arg>
+ <arg
choice='plain'><replaceable>report-name</replaceable></arg>
</cmdsynopsis>
</Synopsis>
</RefSynopsisDiv>
@@ -50,18 +48,11 @@ Generate reports from Spacewalk server in csv format
</para>
<para>
- The command takes some general options, specified on the command
- line before the report name. Each report may have a set of
- report-specific options, those are placed on the command line
- after the report name.
-</para>
-
-<para>
If the report name is not specified, list of available report
names is printed, one name per line.
</para>
-<RefSect1><Title>General Options</Title>
+<RefSect1><Title>Options</Title>
<variablelist>
<varlistentry>
<term>--info</term>
@@ -106,11 +97,6 @@ Generate reports from Spacewalk server in csv format
<command>spacewalk-report</command>.
</listitem>
</varlistentry>
-</variablelist>
-</RefSect1>
-
-<RefSect1><Title>Report-specific Options</Title>
-<variablelist>
<varlistentry>
<term>--list-fields</term>
<listitem>
@@ -119,10 +105,11 @@ Generate reports from Spacewalk server in csv format
</listitem>
</varlistentry>
<varlistentry>
- <term>--info</term>
+ <term>--list-fields-info</term>
<listitem>
- <para>Used with <option>--list-fields</option>, the list
- of fields has description shown as well.</para>
+ <para>Instead of running the report, shows fields that the
+ report has, one field name per line, and a description of
+ that field.</para>
</listitem>
</varlistentry>
</variablelist>