# runtime/entrypoints/chapter.entrypoint.ts

> 39 lines of code and 4 definitions.

Tree: Build tree
Language: typescript
Layer: runtime
Canonical: https://banes-lab.com/anatomy/build#file-build-runtime-entrypoints-chapter-entrypoint-ts
Source text: https://banes-lab.com/assets/sources/source.b8364b6a2f1650e37abb8c6131becbad29c0a92fdb9d617d64f8b5c20e609435.generated.txt

## Definitions

- `argv` (lexical_declaration, line 16)
- `requested` (lexical_declaration, line 25)
- `shape` (lexical_declaration, line 26)
- `result` (lexical_declaration, line 31)

## Source

```typescript
import {
    CHAPTERS_DONE,
    CHAPTER_REMOVED,
    CHAPTER_WRITTEN,
    RENDER_STABLE,
    SHAPE_UNKNOWN,
} from "#configuration/strings/derivation.strings";
import { CHAPTER_SUMMARY, OUT_DESCRIBE, SHAPE_DESCRIBE } from "#configuration/strings/contract.strings";
import { OUT_FLAG, SHAPE_FLAG } from "#configuration/constants/chapter.constants";
import { flagValue, resolveArgv } from "@govlab/argv";
import { refuse, say } from "#core/reporters/derivation.reporter";
import { CHAPTER_COMMAND } from "#configuration/constants/contract.constants";
import { renderSurface } from "#core/coordinators/chapter.coordinator";
import { shapeOf } from "#core/loaders/chapter.loader";

const argv = resolveArgv({
    command: CHAPTER_COMMAND,
    flags: [
        { describe: OUT_DESCRIBE, name: OUT_FLAG, takesValue: true },
        { describe: SHAPE_DESCRIBE, name: SHAPE_FLAG, takesValue: true },
    ],
    summary: CHAPTER_SUMMARY,
});

const requested = flagValue(argv, SHAPE_FLAG) ?? null;
const shape = shapeOf(requested);
if (shape === null) {
    refuse(`${SHAPE_UNKNOWN}${requested ?? ""}`);
}

const result = await renderSurface(shape, flagValue(argv, OUT_FLAG) ?? null);
if (!result.ok) {
    refuse(result.reason);
}
say(RENDER_STABLE);
for (const name of result.removed) {
    say(`${CHAPTER_REMOVED}${name}`);
}
for (const chapter of result.chapters) {
    say(`${CHAPTER_WRITTEN}${chapter.file}`);
}
say(`${String(result.chapters.length)}${CHAPTERS_DONE}${result.out}`);
```
