Skip to content

resolveRenderContext

Generated reference page for the resolveRenderContext function export.

Signatures

ts
function resolveRenderContext(argv: readonly string[], options?: RenderContextOptions): RenderContext;
ParameterTypeDescription
argvreadonly string[]Raw argv tokens (NOT including the binary/script path,
i.e. equivalent to process.argv.slice(2)).
optionsRenderContextOptions | undefinedHost facts and overrides.

Members

Members

resolveRenderContext

Resolve the render context for content built before .run().

Content styled ahead of execution — hand-rendered banners, custom help, or anything else emitted outside an action handler — has no out to consult, which pushes consumers into re-deriving the framework's decisions from raw argv (argv.includes('--json') misreads a post--- literal). This probe runs the same composition .execute()/.run() feed into the output channel — ---aware --json detection, the color gate, and the hyperlink override — so pre-run styling matches the channel that will render.

ts
(argv: readonly string[], options?: RenderContextOptions): RenderContext;

Examples

ts
const ctx = resolveRenderContext(process.argv.slice(2), {
  isTTY: process.stdout.isTTY === true,
  env: process.env,
});
const banner = ctx.color.bold('mycli');

See Also

Released under the MIT License.