Skip to content

Commit

Permalink
Use inspect.getdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ddutt committed Oct 4, 2021
1 parent fccf18d commit 803060f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions suzieq/cli/sqcmds/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,16 @@ def help(self, command: str = ''):
Style.RESET_ALL)
print("\nSupported verbs are: ")
for verb in verbs:
if verbs[verb].__doc__:
docstr = verbs[verb].__doc__.splitlines()[0]
docstr = inspect.getdoc(verbs[verb])
if docstr:
docstr = docstr.splitlines()[0]
else:
docstr = ''
verb = verb.replace('aver', 'assert')
print(f" - {verb}: " + Fore.CYAN + f"{docstr}" +
Style.RESET_ALL)
print(f"\nUse " + Fore.CYAN + f"{self.sqobj.table} help command=<verb>" +
Style.RESET_ALL + " for more details on that verb")
else:
self._do_help(self.sqobj.table, command)

Expand Down Expand Up @@ -287,9 +290,9 @@ def _do_help(self, table: str, verb: str = 'show'):
fnargs = elem[1]
break

docstr = [x[1] for x in fnmbrs if x[0] == '__doc__']
docstr = inspect.getdoc(fnlist[newverb])
if docstr:
docstr = docstr[0].splitlines()[0]
docstr = docstr.splitlines()[0]
else:
docstr = ''
print(f"{table} {verb}: " + Fore.CYAN +
Expand Down

0 comments on commit 803060f

Please sign in to comment.