@porosys/ndtool
Version:
Netdata alert and automation tool
29 lines (28 loc) • 1.09 kB
JavaScript
import { input, select } from '@inquirer/prompts';
import chalk from 'chalk';
import { loadConfig, saveConfig } from '../config.js';
export const configCommand = async () => {
const currentConfig = await loadConfig();
if (!currentConfig) {
console.log(chalk.yellow('⚠️ No config found. Run `ndtool install` first.'));
return;
}
console.log(chalk.green.bold('\n⚙️ Current ndtool Configuration\n'));
console.log(currentConfig);
const port = await input({
message: 'Netdata Web UI Port:',
default: currentConfig.port,
});
const restartPolicy = await select({
message: 'Restart Netdata after config changes?',
choices: [
{ name: 'Always', value: 'always' },
{ name: 'Ask me every time', value: 'ask' },
{ name: 'Never', value: 'never' },
],
default: currentConfig.restartPolicy,
});
const answers = { port, restartPolicy };
await saveConfig(answers);
console.log(chalk.green('\n✅ Configuration updated and saved to ~/.ndtoolrc'));
};