1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-08 22:36:48 +02:00

import cleanup and use all_parser_info in parsers_text

This commit is contained in:
Kelly Brazil
2022-03-14 11:35:57 -07:00
parent 7dac2f8dc3
commit ff9527a098

View File

@@ -4,14 +4,13 @@ JC cli module
import sys import sys
import os import os
import importlib
import textwrap import textwrap
import signal import signal
import shlex import shlex
import subprocess import subprocess
import json import json
from .lib import (__version__, parser_info, all_parser_info, parsers, 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 utils
from . import tracebackplus from . import tracebackplus
from .exceptions import LibraryNotInstalled, ParseError from .exceptions import LibraryNotInstalled, ParseError
@@ -155,17 +154,14 @@ def parser_shortname(parser_arg):
def parsers_text(indent=0, pad=0): def parsers_text(indent=0, pad=0):
"""Return the argument and description information from each parser""" """Return the argument and description information from each parser"""
ptext = '' ptext = ''
for parser in parsers: padding_char = ' '
parser_arg = _parser_argument(parser) for p in all_parser_info():
parser_mod = _get_parser(parser) parser_arg = p['argument']
padding = pad - len(parser_arg)
if hasattr(parser_mod, 'info'): parser_desc = p['description']
parser_desc = parser_mod.info.description indent_text = padding_char * indent
padding = pad - len(parser_arg) padding_text = padding_char * padding
padding_char = ' ' ptext += indent_text + parser_arg + padding_text + parser_desc + '\n'
indent_text = padding_char * indent
padding_text = padding_char * padding
ptext += indent_text + parser_arg + padding_text + parser_desc + '\n'
return ptext return ptext