From 3abd4b7890a50b8e337b22e8aa121dffb4cf2611 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 17 Jun 2013 23:00:32 +0200 Subject: allow skipping usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/argparser.py | 21 +++++++++++---------- 1 file 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: -- cgit v1.2.3-70-g09d2