@jsnix/pastel
Version:
Framework for effortlessly building Ink apps
85 lines (84 loc) • 2.12 kB
TypeScript
import { Instance, RenderOptions } from 'ink';
import type { ComponentType } from 'react';
export interface PastelInterface {
get renderOptions(): RenderOptions | undefined;
set render(render: Instance);
get render(): Instance | undefined;
/**
* Run the app.
*/
run(argv: string[]): Promise<Instance>;
}
export type AppProps = {
/**
* Command's component.
*/
Component: ComponentType<{
options: Record<string, unknown>;
args: unknown[];
app: PastelInterface;
}>;
/**
* Props to pass to command's component.
*/
commandProps: {
/**
* Options.
*/
options: Record<string, unknown>;
/**
* Arguments.
*/
args: unknown[];
/**
* Reference to created Pastel instance
*/
app: PastelInterface;
};
};
/**
* Additional metadata for an option.
*/
export type CommandOptionConfig = {
/**
* Description. If description is missing, option won't appear in the "Options" section of the help message.
*/
description?: string;
/**
* Description of a default value.
*
* @default JSON.stringify(defaultValue)
*/
defaultValueDescription?: string;
/**
* Description of a value. Replaces "value" in `--flag <value>` in the help message.
*
* @default "value"
*/
valueDescription?: string;
/**
* Alias. Usually a first letter of the full option name.
*/
alias?: string;
};
/**
* Additional metadata for an argument.
*/
export type CommandArgumentConfig = {
/**
* Argument's name. Displayed in "Usage" part of the help message. Doesn't affect how argument is parsed.
*
* @default "arg"
*/
name?: string;
/**
* Description of an argument. If description is missing, argument won't appear in the "Arguments" section of the help message.
*/
description?: string;
/**
* Description of a default value.
*
* @default JSON.stringify(defaultValue)
*/
defaultValueDescription?: string;
};