Documentation
¶
Overview ¶
Package scaffold renders the starter Saga `draugr init` writes for a source tree.
It holds the part of init that decides what a descriptor says, and none of what writes it or prints a summary, so every caller that proposes a descriptor for a directory proposes the same one: the CLI writes it to a file, and the MCP server returns it for an assistant to show.
Index ¶
- Constants
- func FilePaths(files []manifests.File) []string
- func GoModules(t inventory.Tree) []string
- func Model(t inventory.Tree, name string) (*saga.Model, error)
- func NameFor(dir string) string
- func OneLine(path string) string
- func PathList(paths []string) string
- func ProjectName(dir string) string
- func RepositoryURL(dir string) string
- func Saga(t inventory.Tree, name string, perDirectory bool) string
- func SagaAt(t inventory.Tree, name string, perDirectory bool, url string) string
- func Scalar(s string) string
Constants ¶
const Here = "."
Here is the url a scaffold gives the repository of the directory it describes. A relative repository url resolves against the directory Draugr runs in, and a scaffold is written to be run from the directory it describes.
Variables ¶
This section is empty.
Functions ¶
func Model ¶ added in v0.163.0
Model is the descriptor Saga writes for the tree, read back as Draugr reads one: one component, with every scanner the tree calls for and nothing that Saga leaves commented out.
Read from the text rather than built beside it, so a scan with no descriptor runs what `draugr init` would write for the same directory, and a scanner added to one is added to the other. A second construction would agree with the text until the day somebody changed only one of them.
func NameFor ¶ added in v0.159.0
NameFor is the name a scaffold gives the project and the component for dir: the last element of its absolute path, folded by ProjectName.
func OneLine ¶ added in v0.163.0
OneLine is a path as a comment or a terminal can carry it: unchanged, or quoted with Go's escapes where it holds a control character or a line break.
A file name may hold a newline, and a scaffold writes paths into YAML comments. Unquoted, the text after the newline would be read as part of the descriptor, and a scan with no descriptor reads this text as its own configuration. YAML also breaks a line at U+0085, U+2028 and U+2029.
func PathList ¶
PathList joins paths with a separator, the first shownPaths of them and a count of the rest.
func ProjectName ¶
ProjectName turns a directory name into one a descriptor accepts.
Lowercase letters, digits and dashes, starting and ending with a letter or digit, which is what `pkg/saga` enforces. Anything else becomes a dash, runs of dashes collapse, and the ends are trimmed. A name with nothing usable left in it, which a directory of punctuation or of non-Latin script produces, falls back to the same placeholder an unnamed directory gets: a scaffold somebody renames beats one that will not load.
func RepositoryURL ¶ added in v0.159.0
RepositoryURL is the url a descriptor read from the working directory gives the repository in dir: Here for the working directory itself, the relative path for a directory beneath it, and the absolute path for any other.
For the directory a scaffold describes, run from that directory, it is the Here the scaffold writes.
func Saga ¶
Saga renders a starter Saga for what the tree holds, run from the directory it describes.
func SagaAt ¶ added in v0.165.3
SagaAt renders a starter Saga for what the tree holds, with url as the repository of every component: Here for a Saga run from the directory it describes, or the directory's path from where the Saga runs.
func Scalar ¶ added in v0.135.1
Scalar is s as a YAML scalar that reads back as the same string, in a block mapping or inside a flow sequence: bare where it would, double-quoted where YAML would read it as a number, a boolean or null (2024, 1e3, 0x10, true) or where it holds a character that means something in YAML. Names and paths come from directory names, which can be any of these.
The YAML 1.1 booleans are quoted too, because an editor's parser may read yes and on as true, and the schema then rejects the value.
Types ¶
This section is empty.