UNPKG

1.58 kBTypeScriptView Raw
1import { flags as F } from '@oclif/command';
2export declare function table<T extends object>(data: T[], columns: table.Columns<T>, options?: table.Options): void;
3export declare namespace table {
4 export const Flags: {
5 columns: F.IOptionFlag<string | undefined>;
6 sort: F.IOptionFlag<string | undefined>;
7 filter: F.IOptionFlag<string | undefined>;
8 csv: F.IFlag<boolean>;
9 output: F.IOptionFlag<string | undefined>;
10 extended: F.IFlag<boolean>;
11 'no-truncate': F.IFlag<boolean>;
12 'no-header': F.IFlag<boolean>;
13 };
14 type IFlags = typeof Flags;
15 type ExcludeFlags<T, Z> = Pick<T, Exclude<keyof T, Z>>;
16 type IncludeFlags<T, K extends keyof T> = Pick<T, K>;
17 export function flags(): IFlags;
18 export function flags<Z extends keyof IFlags = keyof IFlags>(opts: {
19 except: Z | Z[];
20 }): ExcludeFlags<IFlags, Z>;
21 export function flags<K extends keyof IFlags = keyof IFlags>(opts: {
22 only: K | K[];
23 }): IncludeFlags<IFlags, K>;
24 export type Columns<T extends object> = {
25 [key: string]: Partial<Column<T>>;
26 };
27 export interface Column<T extends object> {
28 header: string;
29 extended: boolean;
30 minWidth: number;
31 get(row: T): any;
32 }
33 export interface Options {
34 [key: string]: any;
35 sort?: string;
36 filter?: string;
37 columns?: string;
38 extended?: boolean;
39 'no-truncate'?: boolean;
40 output?: string;
41 'no-header'?: boolean;
42 printLine?(s: any): any;
43 }
44 export {};
45}