UNPKG

@magicdawn/x-args

Version:

play with cli commands like a composer

57 lines (56 loc) 1.74 kB
import { Command, Usage } from "clipanion"; import { ExecSyncOptionsWithBufferEncoding } from "node:child_process"; //#region src/util/BaseCommand.d.ts declare abstract class BaseCommand extends Command { /** * glob */ files: string; ignoreCase: boolean; globCwd: string | undefined; yes: boolean; showTokens: boolean; abstract execute(): Promise<number | void>; } //#endregion //#region src/util/file.d.ts interface FilenameTokens { fullpath: string; dir: string; file: string; name: string; ext: string; pdir: string; rname: string; } declare function getFilenameTokens(item: string): FilenameTokens; declare function renderFilenameTokens(template: string, options: FilenameTokens): string; declare function printFilenameTokens(tokens: FilenameTokens): void; //#endregion //#region src/commands/txt.d.ts declare class TxtCommand extends Command { static paths?: string[][]; static usage: Usage; txt: string; command: string; yes: boolean; wait: boolean; waitTimeout: string | undefined; session: string; execute(): Promise<number | void>; } declare enum SessionControl { Start = "start", ReStart = "restart", Continue = "continue", } type TxtCommandContext = Pick<TxtCommand, 'txt' | 'command' | 'yes' | 'wait' | 'waitTimeout'> & { session: SessionControl; execOptions?: Partial<ExecSyncOptionsWithBufferEncoding>; }; declare const defaultTxtCommandContext: { session: SessionControl.Continue; }; declare function startTxtCommand(ctx: TxtCommandContext): Promise<void>; //#endregion export { BaseCommand, FilenameTokens, SessionControl, TxtCommand, TxtCommandContext, defaultTxtCommandContext, getFilenameTokens, printFilenameTokens, renderFilenameTokens, startTxtCommand };