Guides
Embedding and testing
Use runtime injection and lifecycle hooks to test commands deterministically or embed them into larger tools.
clily is easier to test when you stop treating process.argv and process.exit as the only possible execution boundary.
Runtime overrides
const run = clily({
name: 'backup',
runtime: {
stdout: (message) => captured.push(message),
exit: ({ code }) => exitRequests.push(code),
},
})Useful hooks
onParseonValidateonErroronExitonValidationErroronPromptSelectonHelp
Why this matters
This model lets you:
- capture output without mocking global console behavior
- assert exit reasons without killing the test process
- run commands inside another tool or application shell
- build reproducible examples for different runtimes
The fish runtime example in the monorepo is a good reference for intercepted stdout and exit handling.