Skip to content

Commit

Permalink
General changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sxnic committed Jan 15, 2020
1 parent 375152b commit ac82e65
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions pyfiglet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import shutil
import sys
import zipfile
from optparse import OptionParser

from optparse import OptionParser, HelpFormatter
from ._vendor.optparse_pretty import CompactColorHelpFormatter

from .version import __version__

Expand Down Expand Up @@ -192,7 +194,7 @@ def isValidFont(cls, font):
def getFonts(cls):
all_files = pkg_resources.resource_listdir('pyfiglet', 'fonts')
if os.path.isdir(SHARED_DIRECTORY):
all_files += os.listdir(SHARED_DIRECTORY)
all_files.extend(os.listdir(SHARED_DIRECTORY))
return [font.rsplit('.', 2)[0] for font
in all_files
if cls.isValidFont(font)]
Expand Down Expand Up @@ -889,8 +891,26 @@ def parse_color(color):


def main():
ColorFormatter = CompactColorHelpFormatter(
heading_color="white-bold",
usage_color="white-bold-underline",
shopt_color="white",
lopt_color="white",
help_color="yellow",
metavar_color="white-bold",
description_color="white",
)

# Check if the system supports ANSI escape codes
plat = sys.platform
supported = (plat != "Pocket PC" and (plat != "win32" or "ANSICON" in os.environ))
is_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() or False
is_ansi = (supported and is_tty)

parser = OptionParser(version=__version__,
usage='%prog [options] [text..]')
usage='%prog [options] [text..]',
description="Pure-python FIGlet implementation", formatter=ColorFormatter if is_ansi else HelpFormatter)

parser.add_option('-f', '--font', default=DEFAULT_FONT,
help='font to render with (default: %default)',
metavar='FONT')
Expand Down

0 comments on commit ac82e65

Please sign in to comment.