blockOffunctionfunction blockOf(text: string, name: string, style: Style): Result<string | undefined, BlockError>The body of a block, or none where it is not there.
Managed blocks (commons data 0047-arcactl-init FR-002): the one way arcactl changes a file that a person also edits. A block is a run of lines between two marker lines that name it; arcactl writes only inside its markers, so the rest of the file is the person's and is never touched. Putting a block in twice is the same as once, taking it out leaves the file as it was, and a file whose markers do not make sense (one is missing, or the block is there twice) is an error value and is not changed.
The line ending of the file is kept. Taking a block out restores the file exactly where the file ended with a line ending (or was empty) when the block was put in.
blockOffunctionfunction blockOf(text: string, name: string, style: Style): Result<string | undefined, BlockError>The body of a block, or none where it is not there.
markersconstconst markers: (name: string, style: Style) => { readonly open: string; readonly close: string; }The two marker lines of a block.
Styletypeno test imports ittype Style = "#" | "--";The comment mark of the file the block is in: # for most, -- for psql's.
withBlockfunctionfunction withBlock(text: string, name: string, style: Style, body: string): Result<string, BlockError>The text with the block put in: replaced where it is there, added at the end where it is not.
| Parameter | What it is |
|---|---|
text | the file's text |
name | the block's name |
style | the file's comment mark |
body | what is inside the markers, as lines |
Returns: the new text, or what is wrong with the markers
withoutBlockfunctionfunction withoutBlock(text: string, name: string, style: Style): Result<string, BlockError>The text with the block taken out, and the blank line that was put before it where there is one.
| Parameter | What it is |
|---|---|
text | the file's text |
name | the block's name |
style | the file's comment mark |
Returns: the new text, or what is wrong with the markers