import { AppData } from "../data/app-data";

type Params = {
    cmd: string;
    cwd?: string;
    flags?: string[];
    port: number;
};

export default function grabTtydCmd({
    cmd: ttydCmd,
    cwd,
    flags,
    port,
}: Params) {
    let cmd = ``;
    cmd += `${AppData["TerminalBinName"]}`;
    cmd += ` --writable`;
    // cmd += ` --max-clients 1`;
    cmd += ` --client-option 'theme={"background":"#0c0e11"}'`;
    cmd += ` --client-option fontSize=14`;

    if (cwd) {
        cmd += ` --cwd ${cwd}`;
    }

    if (flags?.[0]) {
        for (let i = 0; i < flags.length; i++) {
            const flag = flags[i];
            cmd += ` ${flag}`;
        }
    }

    cmd += ` -p ${port}`;
    cmd += ` ${ttydCmd}`;

    return { cmd, port };
}
