@swell/cli
Version:
Swell's command line interface/utility
76 lines (75 loc) • 2.44 kB
TypeScript
import { Command } from '@oclif/core';
/**
* Represents a type variant with conditional flag requirements.
* Used for complex commands like `create app` where different types
* have different required/optional flags.
*/
export interface TypeVariant {
/** Type name (e.g., 'admin', 'theme', 'integration') */
name: string;
/** Short description of what this type does */
description: string;
/** Flags required when using this type */
requires?: string[];
/** Flags optionally available for this type */
optional?: string[];
}
/**
* Represents a simpler variant option where one argument maps to one flag.
* Used for commands like `create function` where trigger type determines the flag.
*/
export interface VariantOption {
/** Variant name (e.g., 'model', 'cron', 'route') */
name: string;
/** Flag signature (e.g., '-e, --events=<value>') */
flag: string;
/** Description of what this flag does */
description: string;
}
/**
* Metadata for custom help formatting.
* Add this as a static property on commands that need enhanced help output.
*/
export interface HelpMeta {
/**
* Custom usage line for direct/non-interactive mode.
* Example: '<id> -t <type> [...] -y'
*/
usageDirect?: string;
/**
* Type section for complex conditional dependencies.
* Renders as a detailed breakdown showing each type with its requirements.
*/
typeSection?: {
/** Section title (e.g., 'APP TYPES') */
title: string;
/** List of type variants */
types: TypeVariant[];
};
/**
* Flags to group into a separate "TYPE OPTIONS" section.
* These are excluded from the general FLAGS section.
*/
typeFlags?: string[];
/**
* Variant section for simpler conditional dependencies.
* Renders as a compact table: variant -> flag -> description
*/
variantSection?: {
/** Section title (e.g., 'TRIGGER OPTIONS') */
title: string;
/** List of variant options */
variants: VariantOption[];
};
/**
* Flags to exclude from the general FLAGS section when using variantSection.
*/
variantFlags?: string[];
}
/**
* Command class with optional helpMeta static property.
* Uses Command.Cached since that's what Help receives from Command.Loadable.
*/
export type CommandClassWithMeta = Command.Cached & {
helpMeta?: HelpMeta;
};