mirror of
https://github.com/directus/directus.git
synced 2026-01-28 06:08:01 -05:00
* merge components merge args, parser, docs, formatter, help and handlers * change directus command and add auto debug * output format fixes * adds back some reformatted and documented commands * better help output format * refactor all output flow * export cli types * more formatting fixes and param rework * fix table spacing * add yaml formatting and fix string colors * finished formatting docs * remove log * remove package-lock * update dependency versions * fix command description * workaround typescript loading * module loading fixes added command error rename human to table fix disconnect usage * add typescript loader redirect execution to local package if installed locally added command alias `directus-ctl` * fix module load directories * reimplement stdin pipe to work on linux * fix sdk server info type * info command * Fix stdin bug Disable community extensions to discourage use for now Added template to config files Added password stdin to connect to instances Fixed typescript command load * Added command suggestions and QOL features * Linter fixes * Add command hints * Separate positional options * Add back delete many, fix delete one location * Change score logic * Add whoami util command * Add short online docs * Fix typo * Fix typo * Update commands * Param consistency fix and docs update * Create commands * Update package.json version * Update package-lock * Fixed several linting problems * Update dependencies * Update lock * Remove locked dependencies * Stop conflicts when in home directory * Package lock update and npm audit fix * Fix formatting errors * Comment out extending cli section until we figure out cli ext * Update readme * Tweak dev/build/prebuild script naming * Use up to date deps * Fix dependency version in lock (fix build) Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
77 lines
2.2 KiB
TypeScript
77 lines
2.2 KiB
TypeScript
import { WriteStream } from 'fs';
|
|
import { Argv } from 'yargs';
|
|
import { CLIError } from './core/exceptions';
|
|
import { CommandHelp, GeneralHelp } from './help';
|
|
|
|
export type Options = {
|
|
format: string;
|
|
};
|
|
|
|
export type TableStyle = 'compact' | 'minimal' | 'markdown';
|
|
|
|
export type TableCellAlignment = 'left' | 'center' | 'right';
|
|
|
|
export type TableOptions = {
|
|
head?: string[];
|
|
headFormat?: (text: string) => string;
|
|
style?: TableStyle;
|
|
widths?: (number | null)[];
|
|
alignments?: TableCellAlignment[];
|
|
wrap?: boolean;
|
|
truncate?: boolean;
|
|
};
|
|
|
|
export type TextLayoutOptions = {
|
|
style: (text: string) => string;
|
|
padding: [number, number, number, number];
|
|
alignment: TableCellAlignment;
|
|
removeIndent: boolean;
|
|
};
|
|
|
|
export type OutputColumn = {
|
|
text: string;
|
|
options?: Partial<TextLayoutOptions>;
|
|
};
|
|
|
|
export type Style = (text: string) => string;
|
|
|
|
export interface IUIComposer {
|
|
configure(opts: { indent?: number; width?: number }): void;
|
|
header(name: string, style?: Style): Promise<void>;
|
|
skip(lines?: number): Promise<void>;
|
|
markdown(src: string): string;
|
|
line(value: string): Promise<void>;
|
|
text(text: string): Promise<void>;
|
|
rows(data: OutputColumn[][]): Promise<void>;
|
|
figlet(text: string): Promise<void>;
|
|
table(value: string[][], options?: TableOptions): Promise<void>;
|
|
section(name: string, wrapper?: (builder: IUIComposer) => Promise<void>, style?: Style): Promise<void>;
|
|
wrap(wrapper: (builder: IUIComposer) => Promise<void>, verticalPadding?: number): Promise<void>;
|
|
error(error: Error): Promise<void>;
|
|
json(value: any, style?: TableStyle): Promise<void>;
|
|
get(): Promise<string>;
|
|
clear(): Promise<void>;
|
|
}
|
|
|
|
export type FormatData = {
|
|
help?: GeneralHelp | CommandHelp;
|
|
text: string[];
|
|
errors: Error[];
|
|
value?: any;
|
|
};
|
|
|
|
export interface IOutputFormat<O extends any = any> {
|
|
registerOptions(options: Argv): Argv<O>;
|
|
format(data: FormatData, options: O): Promise<string>;
|
|
}
|
|
|
|
export interface IOutput {
|
|
registerFormat(name: string, format: IOutputFormat): void;
|
|
help(value: CommandHelp | GeneralHelp): Promise<void>;
|
|
text(value: string): Promise<void>;
|
|
value<T>(value: T): Promise<void>;
|
|
error(value: CLIError): Promise<void>;
|
|
compose(builder: (ui: IUIComposer) => Promise<void>): Promise<void>;
|
|
flush(stream: WriteStream): Promise<void>;
|
|
}
|