Skip to content
Snippets Groups Projects
Commit 004c73dc authored by michael.minelli's avatar michael.minelli
Browse files

Settings => Add command to enable / disable interactive mode

parent ece10895
No related branches found
No related tags found
No related merge requests found
Pipeline #38760 passed
import CommanderCommand from '../CommanderCommand.js'; import CommanderCommand from '../CommanderCommand.js';
import SettingsApiCommand from './subcommands/SettingsApiCommand'; import SettingsApiCommand from './subcommands/SettingsApiCommand';
import SettingsInteractiveModeCommand from './subcommands/SettingsInteractiveModeCommand';
class SettingsCommand extends CommanderCommand { class SettingsCommand extends CommanderCommand {
...@@ -12,6 +13,7 @@ class SettingsCommand extends CommanderCommand { ...@@ -12,6 +13,7 @@ class SettingsCommand extends CommanderCommand {
protected defineSubCommands() { protected defineSubCommands() {
SettingsApiCommand.registerOnCommand(this.command); SettingsApiCommand.registerOnCommand(this.command);
SettingsInteractiveModeCommand.registerOnCommand(this.command);
} }
protected async commandAction(): Promise<void> { protected async commandAction(): Promise<void> {
......
import CommanderCommand from '../../CommanderCommand.js';
import { Option } from 'commander';
import Config from '../../../config/Config';
class SettingsInteractiveModeCommand extends CommanderCommand {
protected commandName: string = 'interactive-mode';
protected defineCommand() {
this.command
.description('enable / disable interactive mode by default')
.addOption(new Option('-i, --interactive', 'ENABLE interactive mode by default'))
.addOption(new Option('-n, --no_interactive', 'DISABLE interactive mode by default').conflicts('interactive')) // WARNING: Due to a bug in commander.js, the conflicts method doesn't work as expected if the command is named no-interactive
.action(this.commandAction.bind(this));
}
protected async commandAction(options: { interactive: boolean, no_interactive: boolean }): Promise<void> {
if ( options.interactive ) {
Config.setInteractiveMode(true);
} else if ( options.no_interactive ) {
Config.setInteractiveMode(false);
} else if ( Config.interactiveMode ) {
await Config.askInteractiveMode();
} else {
this.command.help();
}
}
}
export default new SettingsInteractiveModeCommand();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment