JSON, CLI, Process, And Environment

Warning

This is the current planned CLEAR stdlib design. Full stdlib implementation and stabilization are not planned until v0.3. Treat these pages as design direction, not as a compatibility promise.

Status: planned, self-host required for JSON and CLI basics.

Compiler self-hosting needs enough tooling support to parse options, read/write metadata, run subprocesses for tests/build steps, and inspect the environment. These APIs must be high-level by default but visible to the effect/capability system.

JSON

APIStatusNotes
Json.parse(text)self-host requiredDynamic JSON value first; typed decode later.
Json.generate(value)self-host requiredStable object ordering for compiler metadata.
Json.prettyGenerate(value)self-host requiredTooling output.
config = Json.parse(fs.read("clear.json"));
fs.write("build/metadata.json", Json.prettyGenerate(metadata));

CLI

APIStatusNotes
argvintrinsic todayCurrent process arguments.
Cli.parse(spec, argv)self-host requiredTyped option parser.
opts = Cli.parse([
    Cli.flag("verbose"),
    Cli.option("output", type: String),
], argv);

Process And Environment

APIStatusNotes
env.get(name)plannedEnvironment read effect.
env.set(name, value)plannedEnvironment write effect.
process.currentDirectory()self-host requiredCurrent working directory.
Command{ argv, env, cwd }plannedProcess description.
process.run(command)plannedSpawn and return status.
process.capture(command)plannedSpawn and capture output/status.

Decisions

Source: docs/stdlib/tooling.md