MountNametypeno test imports ittype MountName = Brand<string, "anyfs-cli mount name">;The name of a mount: lower-case words joined by hyphens, two to thirty-two characters, and not the name of a kind of place.
Where a word of a command line points (commons anyfs-cli 0002-anyfs-cli-governance FR-005, FR-006): a plain path on this computer, a mount of the configuration (fleet:/machines), or the address of a store (ssh://host/srv/fleet, memory:scratch). The grammar is a pure function of the word and the names of the mounts, so that what a word means never depends on what is on the disk; a word that looks like a mount (name:) and is none is an error that says so, never a file.
import { parseLocation } from "./location.ts";
const mounts = new Set(["fleet"]);
parseLocation("fleet:/machines", mounts); // { kind: "ok", value: { kind: "mount", mount: "fleet", path: "/machines" } }
parseLocation("./notes.txt", mounts); // { kind: "ok", value: { kind: "local", path: "./notes.txt" } }MountNametypeno test imports ittype MountName = Brand<string, "anyfs-cli mount name">;The name of a mount: lower-case words joined by hyphens, two to thirty-two characters, and not the name of a kind of place.
parseMountNamefunctionfunction parseMountName(text: string): Result<MountName, string>A mount name from text, or why the text is not one.
Locationtypeno test imports ittype Location =
| { readonly kind: "local"; readonly path: string }
| { readonly kind: "mount"; readonly mount: MountName; readonly path: string }
| { readonly kind: "place"; readonly place: Place; readonly path: string };Where a word points. The path of a place is the path inside the store, which is rooted at the root of the place.
LocationProblemtypeno test imports ittype LocationProblem = { readonly code: "E-LOCATION" | "E-MOUNT-UNKNOWN"; readonly message: string };Why a word is not a location.
parseLocationfunctionfunction parseLocation(text: string, mounts: ReadonlySet<string>): Result<Location, LocationProblem>Where a word points, given the names of the mounts. A path inside a mount starts with a slash, or is left out for the root of the mount.