Skip to content

Commit

Permalink
Merge pull request #84 from szabopeter/master
Browse files Browse the repository at this point in the history
CLI: non-interactive text argument
  • Loading branch information
ndeoligence committed Oct 31, 2020
2 parents 0007768 + 30118b4 commit cc8b7d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 7 additions & 2 deletions ascii_art/ascii_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,14 @@ def typewriter(message):
time.sleep(1)


def ascii_text():
"""Converts simple text into random font ascii format text"""
def ascii_textinput():
"""Converts text entered by the user into random font ascii format text"""
text = str(input('\n Enter The Text To Convert To Ascii-Art \n'))
ascii_text(text)


def ascii_text(text: str):
"""Converts simple text into random font ascii format text"""
print(pyfiglet.figlet_format(text, font=random.choice(FONTS)).rstrip())


Expand Down
16 changes: 10 additions & 6 deletions ascii_art/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import click
import sys

from ascii_art.ascii_art import (all_supported_files, ascii_text, process, show_clock, show_credits,
COLOR_OPTIONS, SUPPORTED_IMAGE_TYPES)
from ascii_art.ascii_art import (all_supported_files, ascii_textinput, process, show_clock, show_credits,
COLOR_OPTIONS, SUPPORTED_IMAGE_TYPES, ascii_text)


@click.command()
Expand All @@ -21,10 +21,11 @@
@click.option('--all', is_flag=True, help='convert all supported files')
@click.option('-c', '--color', type=click.Choice(COLOR_OPTIONS, case_sensitive=False), default='black',
help='Set output color')
@click.option('--text', is_flag=True, help='Convert Simple Text Into Ascii Text Format, Enter Text After Prompt')
@click.option('--textinput', is_flag=True, help='Convert Simple Text Into Ascii Text Format, Enter Text After Prompt')
@click.option('--text', default=None, type=str, help='Convert Simple Text Into Ascii Text Format')
@click.option('--types', is_flag=True, help='list supported image formats and exit.')
@click.option('-hr', '--highres', is_flag=True, help='Converts using a wide range of Ascii characters.')
def main(input_files, reverse, save, output, width, credits, clock, all, color, text, types, highres):
def main(input_files, reverse, save, output, width, credits, clock, all, color, textinput, text, types, highres):
"""
Converts an image to a text file, using ascii characters to display it.
"""
Expand All @@ -41,10 +42,13 @@ def main(input_files, reverse, save, output, width, credits, clock, all, color,
if all:
input_files = all_supported_files()

if text:
ascii_text()
if textinput:
ascii_textinput()
return

if text:
ascii_text(text)

for file in input_files:
process(file, reverse=reverse, save=save,
output=output, width=width, color=color.lower(), highres=highres)
Expand Down

0 comments on commit cc8b7d4

Please sign in to comment.