Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ pip install --upgrade xulbux
## CLI Commands

When the library is installed, the following commands are available in the console:
| Command | Description |
| :------------ | :--------------------------------------- |
| `xulbux-help` | shows some information about the library |

| Command | Description |
| :------------ | :--------------------------------------------------------------- |
| `xulbux-help` | Show some information about the library. |
| `xulbux-fc` | Parse and render a string's format codes as ANSI console output. |

<br>

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "xulbux"
version = "1.9.6"
version = "1.9.7"
description = "A Python library to simplify common programming tasks."
readme = "README.md"
authors = [{ name = "XulbuX", email = "xulbux.real@gmail.com" }]
Expand Down Expand Up @@ -117,6 +117,7 @@ keywords = [

[project.scripts]
xulbux-help = "xulbux.cli.help:show_help"
xulbux-fc = "xulbux.cli.tools:render_format_codes"

[tool.flake8]
max-complexity = 12
Expand Down
2 changes: 1 addition & 1 deletion src/xulbux/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__package_name__ = "xulbux"
__version__ = "1.9.6"
__version__ = "1.9.7"
__description__ = "A Python library to simplify common programming tasks."
__status__ = "Production/Stable"

Expand Down
24 changes: 24 additions & 0 deletions src/xulbux/cli/tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from ..format_codes import FormatCodes
from ..console import Console


def render_format_codes():
args = Console.get_args({ "input": "before" })

if not args.input.values:
FormatCodes.print(
"\n[_|i|dim]Provide a string to parse and render\n"
"it's format codes as ANSI console output.[_]\n"
)

else:
ansi = FormatCodes.to_ansi("".join(args.input.values))
ansi_escaped = FormatCodes.escape_ansi(ansi)
ansi_stripped = FormatCodes.remove_ansi(ansi)

print(f"\n{ansi}\n")

if len(ansi) != len(ansi_stripped):
FormatCodes.print(f"[_|i|dim]{ansi_escaped}[_]\n")
else:
FormatCodes.print("[_|i|dim](The provided string doesn't contain any valid format codes.)\n")
Loading