UNPKG

dax

Version:

Cross platform shell tools inspired by zx.

30 lines 1.74 kB
import { CommandBuilder, type RawArg, type TemplateExpr } from "./command.js"; /** @internal */ export type ExtrasObject = Record<string, (...args: any[]) => unknown>; /** Options for creating a custom `$`. */ export interface Create$Options<TExtras extends ExtrasObject> { /** Uses this command builder (or the result of the function applied to * the parent's builder) as the starting point. */ commandBuilder?: CommandBuilder | ((builder: CommandBuilder) => CommandBuilder); /** Extra properties to attach to the resulting `$`. */ extras?: TExtras; } /** Callable/helper surface of a `$` produced by `build$`. */ export interface $Base<TExtras extends ExtrasObject> { (strings: TemplateStringsArray, ...exprs: TemplateExpr[]): CommandBuilder; /** Same as the main tag, but arguments are not escaped. */ raw(strings: TemplateStringsArray, ...exprs: TemplateExpr[]): CommandBuilder; /** Wraps a value so it passes through template interpolation unescaped. */ rawArg<T>(arg: T): RawArg<T>; /** Escapes a string so it can be safely interpolated as a command arg. */ escapeArg(arg: string): string; /** Creates a new `$` derived from this one's state. */ build$<TNewExtras extends ExtrasObject = {}>(opts?: Create$Options<TNewExtras>): $Type<TExtras & TNewExtras>; } /** A `$` produced by `build$`, combining the helper surface with any extras. */ export type $Type<TExtras extends ExtrasObject = {}> = $Base<TExtras> & TExtras; /** Creates a new `$` tagged template. */ export declare function build$<TExtras extends ExtrasObject = {}>(opts?: Create$Options<TExtras>): $Type<TExtras>; /** Default `$` instance. */ export declare const $: $Type; //# sourceMappingURL=dollar.d.ts.map