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

Installation

To install the program, you may use pip or any package manager of your choice as the program is available on PyPI. To install using pip, execute the following command:

pip install terminal-styler

Execution

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

stylet <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

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

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

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>Hello<console.underline>World!</console> How are you?</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.1.2.tar.gz (4.4 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.1.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: terminal_styler-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 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.1.2.tar.gz
Algorithm Hash digest
SHA256 900bc164fa11ca8dd93b878633b7f4136869cbaa59c197810b8bff2a8c2dd420
MD5 5aa792630f55b5672c32a7d2a0ffbe06
BLAKE2b-256 83fdfd1ad07eb4e8acfa595b8898582c717bb5dfab441616c1913ad496d29950

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for terminal_styler-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a70694b92f19c563a592156c764bb5371e9c203e21ec9d1e6c76984c3a3b648
MD5 8b239979428d96ae0ed777e6a0acf700
BLAKE2b-256 8a02f9f117284e7d78abbdda107e77cb236dfa0d9f8a397d93256c31d3b28566

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