From ff9527a098a94c996641fb3fe2f905c8ae5e3063 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 14 Mar 2022 11:35:57 -0700 Subject: [PATCH] import cleanup and use all_parser_info in parsers_text --- jc/cli.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/jc/cli.py b/jc/cli.py index ce6a4f7b..bc802f38 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -4,14 +4,13 @@ JC cli module import sys import os -import importlib import textwrap import signal import shlex import subprocess import json from .lib import (__version__, parser_info, all_parser_info, parsers, - _parser_argument, _get_parser, _parser_is_streaming) + _get_parser, _parser_is_streaming) from . import utils from . import tracebackplus from .exceptions import LibraryNotInstalled, ParseError @@ -155,17 +154,14 @@ def parser_shortname(parser_arg): def parsers_text(indent=0, pad=0): """Return the argument and description information from each parser""" ptext = '' - for parser in parsers: - parser_arg = _parser_argument(parser) - parser_mod = _get_parser(parser) - - if hasattr(parser_mod, 'info'): - parser_desc = parser_mod.info.description - padding = pad - len(parser_arg) - padding_char = ' ' - indent_text = padding_char * indent - padding_text = padding_char * padding - ptext += indent_text + parser_arg + padding_text + parser_desc + '\n' + padding_char = ' ' + for p in all_parser_info(): + parser_arg = p['argument'] + padding = pad - len(parser_arg) + parser_desc = p['description'] + indent_text = padding_char * indent + padding_text = padding_char * padding + ptext += indent_text + parser_arg + padding_text + parser_desc + '\n' return ptext