2024-10-23 08:33:39 -07:00
|
|
|
const fs = require('fs')
|
|
|
|
const readline = require('readline')
|
|
|
|
const path = require('path')
|
|
|
|
|
2024-10-27 02:45:45 -07:00
|
|
|
const configPath = path.join(__dirname, 'variables.json')
|
2024-10-23 08:33:39 -07:00
|
|
|
|
|
|
|
function loadConfig() {
|
|
|
|
const rawData = fs.readFileSync(configPath)
|
2024-10-27 02:45:45 -07:00
|
|
|
return JSON.parse(rawData.toString())
|
2024-10-23 08:33:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function saveConfig(config) {
|
|
|
|
const data = JSON.stringify(config, null, 2)
|
|
|
|
fs.writeFileSync(configPath, data)
|
|
|
|
}
|
|
|
|
|
|
|
|
const rl = readline.createInterface({
|
|
|
|
input: process.stdin,
|
|
|
|
output: process.stdout
|
|
|
|
})
|
|
|
|
|
|
|
|
function startCLI() {
|
|
|
|
const config = loadConfig()
|
|
|
|
|
2024-10-27 02:45:45 -07:00
|
|
|
rl.question('Would you like to activate extra file verification? (yes/no): ', (answer) => {
|
2024-10-27 02:57:28 -07:00
|
|
|
if (answer.trim().startsWith('//')) {
|
|
|
|
console.log('This is a comment; the line is ignored.')
|
2024-10-23 08:33:39 -07:00
|
|
|
rl.close()
|
|
|
|
return
|
2024-10-27 02:57:28 -07:00
|
|
|
}
|
2024-10-23 08:33:39 -07:00
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
if (answer.toLowerCase() === 'yes') {
|
2024-10-27 02:45:45 -07:00
|
|
|
config.extraFileVerifActivated = true
|
2024-10-23 08:33:39 -07:00
|
|
|
|
2024-10-26 07:26:54 -07:00
|
|
|
rl.question('Would you like to activate debug mode? (yes/no): ', (debugAnswer) => {
|
2024-10-27 02:45:45 -07:00
|
|
|
config.debug = debugAnswer.toLowerCase() === 'yes'
|
2024-10-23 08:33:39 -07:00
|
|
|
|
2024-10-26 07:26:54 -07:00
|
|
|
rl.question('Would you like to hide or block the menu? (hide/block): ', (menuAnswer) => {
|
2024-10-27 02:57:28 -07:00
|
|
|
if (menuAnswer.trim().startsWith('//')) {
|
|
|
|
console.log('This is a comment; the line is ignored.')
|
2024-10-26 07:26:54 -07:00
|
|
|
rl.close()
|
|
|
|
return
|
2024-10-27 02:57:28 -07:00
|
|
|
}
|
2024-10-24 09:17:46 -07:00
|
|
|
|
2024-10-26 07:26:54 -07:00
|
|
|
if (menuAnswer.toLowerCase() === 'hide') {
|
2024-10-27 02:45:45 -07:00
|
|
|
config.menuVisibility = 'hidden'
|
2024-10-27 02:57:28 -07:00
|
|
|
console.log('Extra file verification activated. Menu hidden.')
|
2024-10-26 07:26:54 -07:00
|
|
|
} else if (menuAnswer.toLowerCase() === 'block') {
|
2024-10-27 02:45:45 -07:00
|
|
|
config.menuVisibility = 'blocked'
|
2024-10-27 02:57:28 -07:00
|
|
|
console.log('Extra file verification activated. Menu blocked.')
|
2024-10-26 07:26:54 -07:00
|
|
|
} else {
|
|
|
|
console.log('Invalid option for the menu.')
|
|
|
|
rl.close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
saveConfig(config)
|
|
|
|
rl.close()
|
|
|
|
})
|
2024-10-23 08:33:39 -07:00
|
|
|
})
|
2024-10-24 09:18:52 -07:00
|
|
|
} else if (answer.toLowerCase() === 'no') {
|
2024-10-27 02:57:28 -07:00
|
|
|
console.log('Extra file verification not activated. Closing the CLI.')
|
2024-10-27 02:45:45 -07:00
|
|
|
config.extraFileVerifActivated = false
|
|
|
|
config.menuVisibility = 'visible'
|
|
|
|
config.debug = false
|
2024-10-23 08:33:39 -07:00
|
|
|
|
|
|
|
saveConfig(config)
|
|
|
|
rl.close()
|
|
|
|
} else {
|
2024-10-24 09:18:52 -07:00
|
|
|
console.log('Invalid response.')
|
2024-10-23 08:33:39 -07:00
|
|
|
rl.close()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
startCLI()
|