Skip to content

Commit

Permalink
logic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
timbrinded committed Nov 1, 2023
1 parent 9bba374 commit 8fbed43
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions packages/cli/src/cmds/runNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,18 @@ const resolveTailChoice = async (env: Environment) => {
let zombieNodePointer: number = 0;
let bottomBarContents = "";
let switchNode: boolean;
let zombieContent: string;
let zombieNodes: string[] | undefined;

const resumePauseProse = [
`, ${chalk.bgWhite.black("[p]")} - pause tail`,
`, ${chalk.bgWhite.black("[r]")} - resume tail`,
`, ${chalk.bgWhite.black("[p]")} Pause tail`,
`, ${chalk.bgWhite.black("[r]")} Resume tail`,
];

const bottomBarBase = `📜 Tailing Logs, commands: ${chalk.bgWhite.black(
"[q]"
)} - quit, ${chalk.bgWhite.black("[t]")} - test, ${chalk.bgWhite.black("[g]")} - grep test`;
)} Quit, ${chalk.bgWhite.black("[t]")} Test, ${chalk.bgWhite.black("[g]")} Grep test`;

bottomBarContents = bottomBarBase + resumePauseProse[0];

const ui = new inquirer.ui.BottomBar({
Expand All @@ -381,15 +383,15 @@ const resolveTailChoice = async (env: Environment) => {
? process.env.MOON_ZOMBIE_NODES.split("|")
: undefined;

bottomBarContents =
bottomBarBase +
resumePauseProse[0] +
`, ${chalk.bgWhite.black("[,]")} Next Log, ${chalk.bgWhite.black(
"[.]"
)} Previous Log | CurrentLog: ${`${zombieNodes[zombieNodePointer]} (${
zombieNodePointer + 1
}/${zombieNodes.length})`}`;
ui.updateBottomBar(bottomBarContents + "\n");
zombieContent = `, ${chalk.bgWhite.black("[,]")} Next Log, ${chalk.bgWhite.black(
"[.]"
)} Previous Log | CurrentLog: ${`${zombieNodes[zombieNodePointer]} (${
zombieNodePointer + 1
}/${zombieNodes.length})`}`;

bottomBarContents = bottomBarBase + resumePauseProse[tailing ? 0 : 1] + zombieContent;

ui.updateBottomBar(bottomBarContents, "\n");
}

switchNode = false;
Expand Down Expand Up @@ -427,13 +429,13 @@ const resolveTailChoice = async (env: Environment) => {
};

const decrPtr = () => {
zombieNodePointer = (zombieNodePointer - 1) % zombieNodes.length;
zombieNodePointer = (zombieNodePointer - 1 + zombieNodes.length) % zombieNodes.length;
};

printLogs(fs.statSync(logFilePath).size, 0);

const renderBottomBar = (...parts: any[]) => {
ui.updateBottomBar(bottomBarBase + " " + parts?.join(" ") + "\n");
ui.updateBottomBar(bottomBarBase + " " + parts?.join(" ") + zombieContent + "\n");
};

const handleInputData = async (key: any) => {
Expand Down

0 comments on commit 8fbed43

Please sign in to comment.