/// <reference types="node" />
/// <reference types="node" />
import { ChildProcess } from 'child_process';
import { IBetterLogger, LogLevel } from '@codiac.io/codiac-common/IBetterLogger';
import * as types from '@codiac.io/codiac-ops-common';
import { CommandResponse, TerminalCommandRequest } from '../message-contracts/terminal-command-request';
export declare class TerminalUtils {
    private logger;
    constructor(logger: IBetterLogger);
    private cliExec;
    execute(request: TerminalCommandRequest): Promise<CommandResponse>;
    /** Fires the given shell command into a child process
     * that inherits the parent's stdio (input, output, and error streams),
     * and resolves the promise on exit of that child process.
     * Returns the exit code from the child process.
     *
     * @param terminalExe The executable to open the terminal.  Examples:  `powershell`, `wsl`, `bash`, `sh`
     * @param terminalArgs Arguments for the terminal executable itself.  Examples:  (for powershell: `["-c"]`, for wsl: `["-d", "ubuntu-20.04", "bash", "-l", "-c"]` OR `["-d", "ubuntu-20.04", "bash", "-l", "--"]`, for bash: `["-c"]`).  IMPORTANT!  Be sure to include the `-c` or `--` arg at the end because these arguments string will be suffixed by the `commandString` parameter of this function.
     * @param commandString the commands to execute from within the terminal process (typically delimited by "&&" or "&"). NOTE: This string will be automatically enclosed in double quotes for final execution, with any existing double-quotes escaped as `\"`, unless you set the `doNotEnquoteCommand` parameter to true on this fucntion
     * @param env If this gets passed in, it replaces the current env.  That is, no env vars from the parent get carried into the child process.
     *            So if you use this param and you still want the current env vars, you'll have to add process.env to your dictionary (use a spread operator).
     * @param collectStdOut (optional, defaults to false) Prevents piping runtime data directly to stdout and instead renders it after completion. Some processes provide runtime status messages (eg: docker's percent completes, etc), which get obstructed by piping to stdout. If so, set this argument to true.
     * @param enquoteCommand (optional, defaults to auto) Setting to true forces enclosing the command string in double quotes for final execution. By default the given commandString param will get appended as is to the terminal command when the last terminal argument is the double-dash: `--`, otherwise it will be enclosed in double quotes (with escaping).
     * */
    spawnTerminalCommands(terminalExe: string, terminalArgs: string[], commandString: string, cwd: string, env?: types.dic, collectStdOut?: boolean, enquoteCommand?: boolean | undefined): Promise<CommandResponse>;
    /** Fires the given shell command into a child process
   * that inherits the parent's stdio (input, output, and error streams),
   * and resolves the promise on exit of that child process.
   * Returns the exit code from the child process.
   * @param env If this gets passed in, it replaces the current env.  That is, no env vars from the parent get carried into the child process.
   *            So if you use this param and you still want the current env vars, you'll have to add process.env to your dictionary (use a spread operator).
   * @param collectStdOut (optional, defaults to false) Prevents piping runtime data directly to stdout and instead renders it after completion. Some processes provide runtime status messages (eg: docker's percent completes, etc), which get obstructed by piping to stdout. If so, set this argument to true.
   * */
    spawnAndLog(cmd: string, cwd: string, env?: types.dic, logLevel?: LogLevel, collectStdOut?: boolean, stdoutEncoding?: BufferEncoding): Promise<[number, string | undefined]>;
    /** Fires the given shell command into a child process
   * that inherits the parent's stdio (input, output, and error streams),
   * and resolves the promise on exit of that child process.
   * Returns the exit code from the child process.
   *
   * @param terminalExe The executable to open the terminal.  Examples:  `powershell`, `wsl`, `bash`, `sh`
   * @param terminalArgs Arguments for the terminal executable itself.  Examples:  (for powershell: `["-c"]`, for wsl: `["-d", "ubuntu-20.04", "bash", "-l", "-c"]` OR `["-d", "ubuntu-20.04", "bash", "-l", "--"]`, for bash: `["-c"]`).  IMPORTANT!  Be sure to include the `-c` or `--` arg at the end because these arguments string will be suffixed by the `commandString` parameter of this function.
   * @param commandString the commands to execute from within the terminal process (typically delimited by "&&" or "&"). NOTE: This string will be automatically enclosed in double quotes for final execution, with any existing double-quotes escaped as `\"`, unless you set the `doNotEnquoteCommand` parameter to true on this fucntion
   * @param env If this gets passed in, it replaces the current env.  That is, no env vars from the parent get carried into the child process.
   *            So if you use this param and you still want the current env vars, you'll have to add process.env to your dictionary (use a spread operator).
   * @param collectStdOut (optional, defaults to false) Prevents piping runtime data directly to stdout and instead renders it after completion. Some processes provide runtime status messages (eg: docker's percent completes, etc), which get obstructed by piping to stdout. If so, set this argument to true.
   * @param enquoteCommand (optional, defaults to auto) Setting to true forces enclosing the command string in double quotes for final execution. By default the given commandString param will get appended as is to the terminal command when the last terminal argument is the double-dash: `--`, otherwise it will be enclosed in double quotes (with escaping).
   * */
    openTerminal(terminalExe: string, terminalArgs: string[], cwd: string, env?: types.dic, collectStdOut?: boolean, enquoteCommand?: boolean | undefined): ChildProcess;
    executeInExistingTerminal(terminal: ChildProcess, command: string): Promise<CommandResponse>;
    /** Returns the exit code (NOTE: this exit code reflects the exit code of the most recently executed command). */
    closeTerminal(term: ChildProcess): Promise<number>;
    /** Equivalent of: `openTerminal() + executeInTerminal() + closeTerminal()`.
     *
     */
    executeSingleCommandInTerminal(terminalExe: string, terminalArgs: string[], command: string, cwd: string, env?: types.dic): Promise<CommandResponse>;
}
