oscli

Non-interactive and CI

Understand TTY detection, no-color behavior, exit codes, and autocomplete hints.

This page covers the runtime behavior that matters in CI, scripts, and piped output. These rules are automatic. You do not need a separate mode switch.

TTY detection

oscli checks stdout at runtime and switches behavior when output is not a TTY. That covers CI, pipes, and test harnesses.

In non-TTY mode, prompts use matching flags, defaults, or optional values. If a required prompt has no value, oscli exits with usage code 2. Spinner animation stops, progress prints sequential lines, and ANSI styling is stripped automatically.

Disable color explicitly

Use these controls when you want plain output even in an interactive terminal.

Prop

Type

Semantic exit codes

Use named exit codes when other tooling needs to branch on failure type.

src/cli.ts
cli.exit("Not authenticated.", { code: "auth" });
cli.exit("File not found.", { code: "not_found" });
cli.exit("Network request failed.", { code: "network" });

Prop

Type

Autocomplete hint

If you expose a completion command elsewhere, you can guide users when they hit unknown commands or flags.

src/cli.ts
export const cli = createCLI(() => ({
  description: "workspace tool",
  autocompleteHint: "Run `oscli completion` to enable tab completion",
}));

That hint prints as a secondary line under the main error.

On this page