@porosys/ndtool
Version:
Netdata alert and automation tool
41 lines (32 loc) • 1.07 kB
text/typescript
import { input, select } from '@inquirer/prompts';
import chalk from 'chalk';
import { loadConfig, saveConfig, NDToolConfig } from '../config';
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 as NDToolConfig);
console.log(
chalk.green('\n✅ Configuration updated and saved to ~/.ndtoolrc'),
);
};