bau/util

Shared filesystem, command, hashing, and terminal helpers.

Consts

BauVersion = "0.5.2"
Version reported by the Bau CLI.
BuildDirName = "build"
Default build artifact directory.
ConfigFileName = "bau.toml"
Primary project configuration filename.
FingerprintDirName = ".bau/fingerprints"
Directory for incremental build fingerprints.
GlobalConfigDir = "bau"
User config directory name below the platform config root.
LocalConfigFileName = "bau.local.toml"
Optional local override filename.

Procs

proc currentColorMode(): string {....raises: [], tags: [], forbids: [].}
Return the active color mode used by terminal helpers.
proc detectAtlas(): string {....raises: [OSError, IOError], tags: [ReadDirEffect,
    ReadEnvEffect, ReadIOEffect], forbids: [].}
Find the atlas executable on PATH, raising if it is unavailable.
proc detectNimCompiler(): string {....raises: [OSError, IOError], tags: [
    ReadDirEffect, ReadEnvEffect, ReadIOEffect], forbids: [].}
Find the nim executable on PATH, raising if it is unavailable.
proc error(msg: string) {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
Print an error message.
proc findConfig(startDir: string = getCurrentDir()): string {.
    ...raises: [ValueError, OSError], tags: [ReadDirEffect], forbids: [].}
Return the nearest bau.toml path, or an empty string when absent.
proc findProjectRoot(startDir: string = getCurrentDir()): string {.
    ...raises: [ValueError, OSError, IOError], tags: [ReadDirEffect], forbids: [].}

Walk upward from startDir until a bau.toml file is found.

Raises IOError when no project root exists in the directory ancestry.

proc globalConfigPath(): string {....raises: [],
                                  tags: [ReadEnvEffect, ReadIOEffect],
                                  forbids: [].}
Return the path to the user-level Bau config file.
proc globalTasksPath(): string {....raises: [],
                                 tags: [ReadEnvEffect, ReadIOEffect],
                                 forbids: [].}
Return the path to the user-level Bau tasks file.
proc hashFile(path: string): string {....raises: [IOError], tags: [ReadIOEffect],
                                      forbids: [].}
Return Bau's prefixed SHA-256 digest for a file's contents.
proc hashStr(data: string): string {....raises: [], tags: [], forbids: [].}
Return Bau's prefixed SHA-256 digest for a string.
proc homeDir(): string {....raises: [], tags: [ReadEnvEffect, ReadIOEffect],
                         forbids: [].}
Return the current user's home directory.
proc info(msg: string) {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
Print an informational message unless quiet output is enabled.
proc nimVersion(): string {....raises: [], tags: [], forbids: [].}
Return the Nim version baked into the compiler that built Bau.
proc platformTriple(): string {....raises: [], tags: [], forbids: [].}
Return the host platform as os-cpu.
proc readFileChecked(path: string): string {....raises: [IOError],
    tags: [ReadIOEffect], forbids: [].}
Read a file, raising an IOError that includes the requested path.
proc runCmd(cmd: string; args: openArray[string] = []; cwd: string = ""): tuple[
    exitCode: int, output: string] {....raises: [OSError, IOError, ValueError], tags: [
    ExecIOEffect, ReadEnvEffect, RootEffect, ReadIOEffect, TimeEffect],
                                     forbids: [].}
Run a command and capture combined stdout and stderr.
proc runCmdChecked(cmd: string; args: openArray[string] = []; cwd: string = ""): string {.
    ...raises: [OSError, IOError, ValueError],
    tags: [ExecIOEffect, ReadEnvEffect, RootEffect, ReadIOEffect, TimeEffect],
    forbids: [].}
Run a command and return captured output, raising on nonzero exit.
proc runCmdLive(cmd: string; args: openArray[string] = []; cwd: string = "") {.
    ...raises: [OSError, IOError, ValueError],
    tags: [ExecIOEffect, ReadEnvEffect, RootEffect, TimeEffect, WriteIOEffect],
    forbids: [].}
Run a command attached to the parent terminal, raising on nonzero exit.
proc runCmdLiveStatus(cmd: string; args: openArray[string] = [];
                      cwd: string = ""): int {.
    ...raises: [OSError, IOError, ValueError],
    tags: [ExecIOEffect, ReadEnvEffect, RootEffect, TimeEffect, WriteIOEffect],
    forbids: [].}
Run a command attached to the parent terminal and return its exit code.
proc saveFile(path: string; content: string) {....raises: [OSError, IOError],
    tags: [WriteDirEffect, ReadDirEffect, WriteIOEffect], forbids: [].}
Write content to path, creating parent directories first.
proc setOutputOptions(quiet: bool; color: string) {....raises: [], tags: [],
    forbids: [].}

Configure process-wide terminal output behavior.

color accepts auto, always, or never; unknown values keep the previous color setting.

proc success(msg: string) {....raises: [IOError], tags: [WriteIOEffect],
                            forbids: [].}
Print a success message unless quiet output is enabled.
proc toTomlString(s: string): string {....raises: [], tags: [], forbids: [].}
Quote a string for TOML output, using multiline syntax when needed.
proc warn(msg: string) {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
Print a warning message.