Output and logging
Write lines through the shared output system and reuse styles where needed.
oscli routes user-facing output through one output layer so logs, prompts,
boxes, progress, and links all stay visually aligned.
Logging
Use cli.log() when you want one line in the normal output flow.
await cli.run(async () => {
cli.log("ready");
cli.log("warn", "review this before production").bold().underline().flush();
cli.success("Done.");
});If you call cli.log(level, message), the returned chain lets you apply text
modifiers before the message is written.
ready
⚠ review this before production
✓ Done.Prop
Type
Reusable styles
Use cli.style() when you want to build a style once and reuse it across
multiple writes.
await cli.run(async () => {
const callout = cli.style().color("cyan").bold();
cli.log("info", callout.render("important"));
cli.log(callout.render("plain line with shared styling"));
}); ℹ important
plain line with shared stylingProp
Type
Exit with hints
Use cli.exit() when the command cannot continue and you want a concrete next
step in the error output.
cli.exit("package.json not found.", {
hint: "Run this command from the project root.",
code: "not_found",
});│
│ ✗ package.json not found.
│ → Run this command from the project root.
└Inline confirm
Use cli.confirm() when you need one simple confirmation in the middle of a
flow without defining a named prompt.
await cli.run(async () => {
const approved = await cli.confirm("Deploy now?", false);
if (!approved) {
cli.exit("Cancelled.");
}
}); Deploy now?
› (y/N) _cli.exit() writes to stderr. cli.log("error", ...) also writes to stderr.
Other output stays on stdout.