@altostra/core
Version:
Core library for shared types and logic
24 lines (23 loc) • 1.01 kB
TypeScript
/**
* Create an escaped shell command argument from given string
* @param arg The argument to escape
* @param quote The quote type to use (default is ")
* @param escape Escape char to use (default is \)
*
* @returns A string if the escaped and quoted shell arg
*/
export declare function escapeArg(arg: string, quote?: '"' | "'", escape?: string): string;
/**
* Tagged template that quote and escape all args
* @example shell`command ${arg1} ${arg2}`
*/
export declare type ShellCommandTaggedTemplate = (strings: TemplateStringsArray, ...values: unknown[]) => string;
/**
* Creates a tagged-template to create shell commands by the provided quote and escape
* @param quote The quote type to use (default is ")
* @param escape Escape char to use (default is \)
*
* @returns A tagged-template to create shell commands
*/
export declare function commandTextBy(quote?: '"' | "'", escape?: string): ShellCommandTaggedTemplate;
export declare const commandText: ShellCommandTaggedTemplate;