Skip to content

Latest commit

 

History

History
64 lines (55 loc) · 1.24 KB

README.md

File metadata and controls

64 lines (55 loc) · 1.24 KB

tcm-d-libs

Collection of in-progress utilities for D-lang. (WIP)

opthandler

import std.stdio, std.regex, std.algorithm, tcm.opthandler;

void main(string[] argv){
  auto opts = new Opt(argv);
  writeln(opts.command());
  writeln(opts.command(1));
  writeln(opts.value("file"));
  writeln(opts.flag("debug"));
}

Outputs:

./app --debug writeln bork --file:me
writeln
bork
me
true

strplus

just a clean API for checking if a string contains a substring

"this is a test string".contains("test"); // returns true

arrayplus

same as strplus.contains

["this", "is", "a", "test"].contains("test"); // returns true

randplus

int i = rand(10); //returns random number between 0 and 10
int r = randrange(10, 100); // returns random number between 10 and 100

colours

Simple class for terminal colours. (Linux) The API is;

.*colour*
.bright_*colour*
.bg_*colour*
.bg_bright_*colour*
.bold
.underline
.reversed
.reset
.fg(colour_id)
.bg(colour_id)

Examples:

auto c = new Colours();
writeln(c.red~"This text is red when it prints!"~c.reset); //reset clears all formatting
writeln(c.fg(125)~"Also takes a colour ID, for fg for foreground, fg for background"~c.reset);