Maneren / Dahlia.sh

Dahlia — a simple text formatting package, inspired by the game Minecraft.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dahlia spec

Dahlia.sh

Dahlia is a simple text formatting package, inspired by text formatting in the game Minecraft.

Text is formatted similarly to the game. With Dahlia, it is formatted by typing a special character & followed by a format code and finally the text to be formatted.

Installation

Download the source and put the dahlia executable in your $PATH.

Dependencies

The scripts are written for GNU Bash 5.0+.

Other dependencies are reasonably modern (if someone knows how to find the minimal required version, please let me know).:

  • GNU grep and sed (non GNU version probably work too but aren't officially supported)
  • GNU coreutils - dirname, sort, uniq

Note: It is expected that all those commands are available in the $PATH.

Usage

See dahlia --help

Dahlia — a simple text formatting package, inspired by the game Minecraft.

Usage:
  dahlia [--] TEXT
    parse the TEXT and color it

  dahlia {clean|clean_ansi} TEXT
    remove Dahlia/ANSI codes from TEXT

  dahlia test
    print short test string

  dahlia {--help|help}
    print this help

Configuration via environment variables:
  DAHLIA_DEPTH - color depth
    either case insensitive string AUTO, TTY, LOW, MEDIUM or HIGH or number of bits 0, 3, 4, 8, 24
    (default or AUTO is tries to infer the best based on the terminal)

  DAHLIA_MARKER - specify what marker to use (default is &)

  DAHLIA_AUTO_RESET - if not 0 auto add reset (default is 1)

Respects NO_COLOR environment variable.

Library

To use Dahlia in your project, source the lib.sh file in your script.

API

The API follows the specification version 1.0. It exposes following public functions:

  • dahlia_convert Format given string with Dahlia (no trailing newline).
  • dahlia_print Format given string with Dahlia and echo it (adds newline as needed).
  • dahlia_input Get user input with Dahlia formatted prompt and return it.
  • dahlia_clean Remove Dahlia formatting codes from given string.
  • dahlia_clean_ansi Remove all ANSI codes from given string.

For more details, see the documentation comments in lib.sh and the specification.

Examples

example usage of the executable

License

Dahlia is licensed under the MIT License.

About

Dahlia — a simple text formatting package, inspired by the game Minecraft.

License:MIT License


Languages

Language:Shell 99.0%Language:Just 1.0%