[patch] print some more usage information [was: Re: parser option handling]
Bernhard Fischer <[email protected]> Sat, 5 May 2007 21:16:22 +0200
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
The attached patch (ontop of bug139) does: - adjust the help text to fit into 80 columns - print help text if no input-files were given ¹) - add -U to the help output The reasoning is that it would be nice if all of $ synopsis $ synopsis -v et al would print a nice help text ¹) -p C -h still works as expected, even if there were no args given. Please consider applying _______________________________________________ Synopsis-devel mailing list [email protected] http://lists.fresco.org/cgi-bin/listinfo/synopsis-devel
synopsis-0.9.1-bb.print-help-for-missing-args.diff
(text/x-diff, 4.2 KB)
--- scripts/synopsis.04 2007-05-05 20:24:03.000000000 +0200
+++ scripts/synopsis 2007-05-05 21:07:43.000000000 +0200
@@ -41,27 +41,28 @@
print 'Usage : %s [options] <input files>'%'synopsis'
print """
List of options:
- -h, --help Display usage summary.
- -V, --version Display version information.
- -v --verbose Operate verbosely.
- -d --debug Operate in debug mode.
- -o <file>, --output=<file> Write output to <file>.
- -p <lang>, --parser=<lang> Select a parser for <lang>.
- -Wp,<arg>[,<arg>...] Send <args> to the parser.
- --translate[=<markup>] Translate comments to doc-strings, processing it as
- <markup> (typical values are 'javadoc' or 'rst').
- --cfilter=<filter> Specify a comment filter.
- --cprocessor=<processor> Specify a comment processor.
- -Wc,<arg>[,<arg>...] Send <args> to the comment translator.
+ -h, --help Display usage summary.
+ -V, --version Display version information.
+ -v --verbose Operate verbosely.
+ -d --debug Operate in debug mode.
+ -o <file>, --output=<file> Write output to <file>.
+ -p <lang>, --parser=<lang> Select a parser for <lang>.
+ -Wp,<arg>[,<arg>...] Send <args> to the parser.
+ --translate[=<markup>] Translate comments to doc-strings, processing it as
+ <markup> (typical values are 'javadoc' or 'rst').
+ --cfilter=<filter> Specify a comment filter.
+ --cprocessor=<processor> Specify a comment processor.
+ -Wc,<arg>[,<arg>...] Send <args> to the comment translator.
-l <processor>,
- --linker=<processor> Link, processing all declarations with <processor>.
- -Wl,<arg>[,<arg>...] Send <args> to the linker.
+ --linker=<processor> Link, processing all declarations with <processor>.
+ -Wl,<arg>[,<arg>...] Send <args> to the linker.
-f <type>,
- --formatter=<type> Select a formatter for <type>.
- -Wf,<arg>[,<arg>...] Send <args> to the formatter.
- -I <path> Add <path> to list of include paths.
- --include=<file> Preinclude <file>.
- -D <macro> Add <macro> to list of predefined macros.
+ --formatter=<type> Select a formatter for <type>.
+ -Wf,<arg>[,<arg>...] Send <args> to the formatter.
+ -I <path> Add <path> to list of include paths.
+ --include=<file> Preinclude <file>.
+ -D <macro> Add <macro> to list of predefined macros.
+ -U <macro> Remove <macro> from list of predefined macros.
"""
def make_processor(argv):
@@ -86,18 +87,17 @@
help = False
opts, args = getopt.getopt(argv,
- 'o:p:l:f:I:D:W:jvhVdP',
+ 'o:p:l:f:I:D:U:W:jvhVdP',
['output=',
'parser=', 'translate=', 'cfilter=', 'cprocessor=',
'linker=', 'formatter=',
'version', 'help', 'verbose', 'debug', 'profile',
'include='])
-
for o, a in opts:
if o in ['-V', '--version']:
print 'synopsis version %s'%config.version
sys.exit(0)
-
+
if o in ['-v', '--verbose']: options['verbose'] = True
elif o in ['-d', '--debug']: options['debug'] = True
elif o in ['-P', '--profile']: options['profile'] = True
@@ -154,6 +154,10 @@
if not parser_opts.get('cppflags'): parser_opts['cppflags'] = []
parser_opts['cppflags'].append('-D%s'%a)
+ elif o == '-U':
+ if not parser_opts.get('cppflags'): parser_opts['cppflags'] = []
+ parser_opts['cppflags'].append('-U%s'%a)
+
elif o == '-W':
if a[0] == "p":
for o,a in get_options(a[2:].split(','), expect_non_options = False):
@@ -180,6 +184,9 @@
if not (parser or linker or formatter):
usage()
sys.exit(0)
+ if not args:
+ usage()
+ sys.exit(0)
# quick hack: if the parser is Cpp, rename the 'cppflags'
# options to just 'flags'