Skip to content

Commit

Permalink
Merge pull request #41 from frostming/feature/drop-py2
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored May 11, 2021
2 parents 5cdbc00 + a366bcf commit db2b8d0
Show file tree
Hide file tree
Showing 8 changed files with 372 additions and 464 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.9
- name: Linting
run: |
pip install flake8
Expand All @@ -24,27 +24,17 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install PDM
run: python -m pip install --upgrade pdm
- name: Set up Python
uses: actions/setup-python@v1
- uses: actions/checkout@v2
- name: Set up PDM
uses: pdm-project/setup-pdm@main
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pdm use -f ${{ matrix.python-version }}
pdm config parallel_install false
pip install wheel setuptools
pdm install -d
run: pdm install -d
- name: Run Tests
run: |
pdm run pytest tests
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
install:
pip install --upgrade pdm wheel
pdm sync -g . -d
pdm sync -gp .

docs:
pdm || $(MAKE) install
Expand Down
2 changes: 1 addition & 1 deletion cfonts/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
:license: GNU GPLv2
:author: Frost Ming<[email protected]>
"""
__version__ = "1.4.0"
__version__ = "1.5.0"
75 changes: 50 additions & 25 deletions cfonts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@


class CFontsArgumentParser(argparse.ArgumentParser):

def format_help(self) -> str:
formatter = self._get_formatter()

# description
formatter._add_item(
lambda x: x,
[render("cfonts", gradient=["red", "green"], space=False) + "\n"]
[render("cfonts", gradient=["red", "green"], space=False) + "\n"],
)
formatter.add_text(self.description)

# usage
formatter.add_usage(self.usage, self._actions,
self._mutually_exclusive_groups)
formatter.add_usage(self.usage, self._actions, self._mutually_exclusive_groups)

# positionals, optionals and user-defined groups
for action_group in self._action_groups:
Expand All @@ -48,29 +46,54 @@ def parse_args():
parser = CFontsArgumentParser(
"cfonts",
description="This is a tool for sexy fonts in the console. "
"Give your cli some love."
"Give your cli some love.",
)
parser.add_argument(
"-V", "--version", action="version", version="{} {}".format(
"-V",
"--version",
action="version",
version="{} {}".format(
render("cfonts", font="console", colors=["candy"], space=False), __version__
)
),
)

parser.add_argument("-f", "--font", default=FONTFACES.block,
choices=FONTFACES.all(), help="Use to define the font face")
parser.add_argument("-c", "--colors", default=COLORS.system,
help="Use to define the font color")
parser.add_argument("-b", "--background", default=BGCOLORS.transparent,
help="Use to define the background color")
parser.add_argument("-a", "--align", default="left",
choices=ALIGNMENT, help="Use to align the text output")
parser.add_argument("-l", "--letter-spacing", type=int,
help="Use to define the letter spacing")
parser.add_argument("-z", "--line-height", default=1,
help="Use to define the line height")
parser.add_argument("-s", "--spaceless", dest="space", default=True,
action="store_false",
help="Use to define the background color")
parser.add_argument(
"-f",
"--font",
default=FONTFACES.block,
choices=FONTFACES.all(),
help="Use to define the font face",
)
parser.add_argument(
"-c", "--colors", default=COLORS.system, help="Use to define the font color"
)
parser.add_argument(
"-b",
"--background",
default=BGCOLORS.transparent,
help="Use to define the background color",
)
parser.add_argument(
"-a",
"--align",
default="left",
choices=ALIGNMENT,
help="Use to align the text output",
)
parser.add_argument(
"-l", "--letter-spacing", type=int, help="Use to define the letter spacing"
)
parser.add_argument(
"-z", "--line-height", default=1, help="Use to define the line height"
)
parser.add_argument(
"-s",
"--spaceless",
dest="space",
default=True,
action="store_false",
help="Use to define the background color",
)

parser.add_argument(
"-m",
Expand All @@ -79,22 +102,24 @@ def parse_args():
help="Use to define the amount of maximum characters per line",
)
parser.add_argument(
"-g", "--gradient", help="Define gradient colors(separated by comma)",
"-g",
"--gradient",
help="Define gradient colors(separated by comma)",
)
parser.add_argument(
"-i",
"--independent-gradient",
action="store_true",
help="Set this option to re-calculate the gradient colors for each new line."
"Only works in combination with the gradient option.",
"Only works in combination with the gradient option.",
)
parser.add_argument(
"-t",
"--transition-gradient",
dest="transition",
action="store_true",
help="Set this option to generate your own gradients. Each color set "
"in the gradient option will then be transitioned to directly.",
"in the gradient option will then be transitioned to directly.",
)
parser.add_argument("text")
if len(sys.argv) == 1:
Expand Down
5 changes: 1 addition & 4 deletions cfonts/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
:license: GNU GPLv2
:author: Frost Ming<[email protected]>
"""
try:
from shutil import get_terminal_size
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size
from shutil import get_terminal_size

SIZE = tuple(get_terminal_size((80, 24)))
CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|!?.+-_=@#$%&()/:;,' \""
Expand Down
3 changes: 0 additions & 3 deletions cfonts/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
:license: GNU GPLv2
:author: Frost Ming<[email protected]>
"""
from __future__ import unicode_literals

import argparse
import json
import pkgutil
Expand Down Expand Up @@ -354,4 +352,3 @@ def say(text, **options):
def _strip_color(text):
regex = re.compile(r"\x1b\[\d+?m")
return regex.sub("", text)

Loading

0 comments on commit db2b8d0

Please sign in to comment.