aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-06-17 23:00:32 +0200
committerMattias Andrée <maandree@operamail.com>2013-06-17 23:00:32 +0200
commit3abd4b7890a50b8e337b22e8aa121dffb4cf2611 (patch)
tree292864d646d61dc4f696333e99a24a4485c6e80d /src
parentm (diff)
downloadargparser-3abd4b7890a50b8e337b22e8aa121dffb4cf2611.tar.gz
argparser-3abd4b7890a50b8e337b22e8aa121dffb4cf2611.tar.bz2
argparser-3abd4b7890a50b8e337b22e8aa121dffb4cf2611.tar.xz
allow skipping usage
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/argparser.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/argparser.py b/src/argparser.py
index 10368f1..624856b 100644
--- a/src/argparser.py
+++ b/src/argparser.py
@@ -52,7 +52,7 @@ class ArgParser():
The short description is printed on same line as the program name
@param description:str Short, single-line, description of the program
- @param usage:str Formated, multi-line, usage text
+ @param usage:str? Formated, multi-line, usage text, may be `None`
@param longdescription:str Long, multi-line, description of the program, may be `None`
@param program:str? The name of the program, `None` for automatic
@param usestderr:str Whether to use stderr instead of stdout
@@ -388,15 +388,16 @@ class ArgParser():
self.__print(self.__longdescription)
self.__print()
- self.__print('\033[01mUSAGE:\033[21m', end='')
- first = True
- for line in self.__usage.split('\n'):
- if first:
- first = False
- else:
- self.__print(' or', end='')
- self.__print('\t%s' % (line))
- self.__print()
+ if self.__usage is not None:
+ self.__print('\033[01mUSAGE:\033[21m', end='')
+ first = True
+ for line in self.__usage.split('\n'):
+ if first:
+ first = False
+ else:
+ self.__print(' or', end='')
+ self.__print('\t%s' % (line))
+ self.__print()
maxfirstlen = []
for opt in self.__options: