Skip to main content

CLI tool for adding foreground and background colours, as well as styles such as bold, underline, and more to your terminal output.

Project description

Terminal Styler

CLI tool for adding foreground and background colours, as well as styles such as bold, underline, and more to your terminal output.

Prerequisites

  • Python
  • Support for ANSI codes in your terminal

Execution

To run the program, execute the following command from the root directory of the project:

python3 main.py <input-file> [<output-file>]

If no output file is specified, the output file will be

styled-<input-file>.

Input File

The input file should be a file containing the text you wish to style. The text can be styled using the following syntax:

<console[.<styles>]>text</console>

Each style is separated by a period.

Eg: <console.bold.underline.color-green>text</console>

The following styles are supported:

  • bold
  • underline
  • reverse-text
  • color-<color>
  • bg-<color>

The following colours are supported:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • grey

Each color has a dark alternative, except black and grey, represented as dark-<color>.

Eg: <console.color-dark-red>text</console>

You may also nest console tags within each other.

Eg: <console.bold>text<console.underline>text</console></console>

RBG colors can be specified in place of the default colors, using the syntax [#hexcode].

Eg: <console.bg-[#ff0000]>text</console>

Note: If you wish to use <console or </console> in your text without it being transpiled, you must prefix 'console' with a bang !

Eg: <!console>text</!console> will be transpiled to <console>text</console>

One exclaimation mark will be removed from after each <, if present.

Output File

The output file will be a copy of the input file, with the text styled according to the input file. If no output file is specified, the output file will be named styled-input-file.

The output file will be of the same type as the input file.

Note: If the output file already exists, it will be overwritten.

Note: The application will not check if the input file is a valid file, or if the output file is a valid file name.

Examples

Input

test.py

print("<console.color-dark-red.bg-green.bold>Hello <console.underline>World!</console></console>")
print("<console.color-[#B8B8B8]>How are you?</console>!")
print("I <console.color-green>am</console> <console.reverse-text.bold>good</console>")

Output

styled-test.py

print("Hello World!")
print("How are you?!")
print("I am good")

Input

Test.java

package test;

public class Test {
    public static void main(String[] args) {
        System.out.println("Hello <console.bold>World!</console>");
    }
}

Output

Test.java

package test;

public class Test {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terminal_styler-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terminal_styler-0.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file terminal_styler-0.0.1.tar.gz.

File metadata

  • Download URL: terminal_styler-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for terminal_styler-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ae57ebc5c1f6509606eae5eee810e4f6612da49dc7dd4770e8f8f231483b5fbb
MD5 2747c1a7054203d11f0d1def56c82df1
BLAKE2b-256 fedd9647691e91135c3d9371b0a86a54f405ff3ca6a630014f36475353846b0c

See more details on using hashes here.

File details

Details for the file terminal_styler-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for terminal_styler-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c240add9fa9b0ff7e0638a07ba41be1b59cc2519a9584cd9189c639fe350f60a
MD5 cabcad7045961c024ab30f6683e3be89
BLAKE2b-256 2d64d8c2088db74a674e52aa18e40f78dbd44f28c1e25e80761c291cb641bf1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page