let arguments = JSON.parse(process.argv[2]); const chalk = require(__dirname + '/../../MistyCore/node_modules/chalk'); const fs = require("fs"); const child_process = require("child_process"); if (arguments._finals.length > 0) { for (let file of arguments._finals) { if (fs.existsSync(file)) { try { fs.accessSync(file, fs.constants.R_OK); if (arguments['hex']) { fs.writeFileSync("/System/Volumes/VM/HexDump", require('./hex')(fs.readFileSync(file), !arguments['pagination'])); file = "/System/Volumes/VM/HexDump"; } if (fs.lstatSync(file).isDirectory()) { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("Is a directory: ") + file); } else { if (arguments['pagination']) { console.clear(); child_process.execFileSync("/System/Binaries/busybox", [ "less", "-~", "-S", "--", file ], { stdio: "inherit" }); console.clear(); } else { if (arguments['search']) { console.log(chalk.white(fs.readFileSync(file).toString().replace(arguments['search'], chalk.bold.red(arguments['search'])))); } else { console.log(chalk.white(fs.readFileSync(file).toString())); } } } if (fs.existsSync("/System/Volumes/VM/HexDump")) fs.unlinkSync("/System/Volumes/VM/HexDump"); } catch (e) { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("Permission denied: ") + file); } } else { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("No such file or directory: ") + file); } } } else { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("Missing operand")); }