ilusm.dev

tag

Build constraints and feature tags - parse a comma-separated tag string, read the active set from the ILUSM_TAGS environment variable, check if a single tag is active, require all of a set of tags (throws on missing), require any of a set of tags, and perform set operations (union, intersection, difference) on tag lists.

Load with: use tag

What this module does

tag implements a lightweight feature-flag and build-constraint system. The source of truth is the ILUSM_TAGS environment variable - a comma-separated list of tag names. The module lets you gate code on the presence of tags at runtime: require them (throwing an error if absent) or branch on them optionally. Tags are normalised to lowercase for comparison.

Quick example

use tag

# Parse ILUSM_TAGS="debug,feature-x,release" from environment
active = tagac()          # ["debug", "feature-x", "release"]

# Check presence
prn(tagha("debug"))       # tru
prn(tagha("staging"))     # fls

# Require tags (throws if missing)
tagre(["release", "debug"])   # ok
tagre(["production"])          # throws "miss production"

# Any of
prn(tagan(["staging", "debug"]))  # tru (debug is active)

# Set operations on fixed lists
a = ["a", "b", "c"]
b = ["b", "c", "d"]
prn(tagun(a, b))   # ["a","b","c","d"]
prn(tagin(a, b))   # ["b","c"]
prn(tagsu(a, b))   # ["a"]

Functions

Environment

tagpa(raw)

Parses a comma-separated tag string into a list of trimmed, non-empty tag strings.

tagac()

Returns the active tag list from os.env("ILUSM_TAGS"), normalised (lowercase, deduped).

tagno(s)

Normalises a tag string: lowercase and trimmed.

Checking

tagha(tag)

Returns tru if tag is in the active tag set.

tagal(tags)

Returns tru if all tags in the list are active.

tagan(tags)

Returns tru if any tag in the list is active.

Requiring (throws on failure)

tagre(required)

Throws an error naming the first missing tag if any tag in required is not active. Use for hard build constraints.

Set operations

tagun(a, b)

Union of tag lists a and b - all unique tags from both.

tagin(a, b)

Intersection - tags present in both a and b.

tagsu(a, b)

Difference - tags in a not in b.

tagme(xs, t)

Returns tru if t is a member of list xs.

Notes

  • Requires txt, trl, os, eru, and slc.