Skip to content

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

License

Notifications You must be signed in to change notification settings

Maneren/Dahlia.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/ZSH 5.9 and newer.

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published