Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a configurable console menu for ease of use #4174

Draft
wants to merge 11 commits into
base: dev
Choose a base branch
from
Prev Previous commit
Next Next commit
Add more skeleton.
  • Loading branch information
demiankatz committed Dec 19, 2024
commit 4abdb979efd68bea90fd93fc1d4b3cdbb83f6480
10 changes: 7 additions & 3 deletions config/vufind/ConsoleMenu.yaml
Original file line number Diff line number Diff line change
@@ -2,8 +2,12 @@ main:
label: Main Menu
type: menu
contents:
- label: Submenu 1
- label: Import Options
type: menu
contents:
- label: Command
type: command
- label: Import MARC
type: external-command
command: import-marc.sh
- label: Import XML
type: internal-command
command: import/import-xsl
Original file line number Diff line number Diff line change
@@ -120,6 +120,36 @@ protected function displaySubmenu(InputInterface $input, OutputInterface $output
}
}

/**
* Run an external (non-Symfony) command.
*
* @param InputInterface $input Input object
* @param OutputInterface $output Output object
* @param array $config Configuration of command to run
*
* @return int
*/
protected function runExternalCommand(InputInterface $input, OutputInterface $output, array $config): int
{
$output->writeLn("Not implemented yet.");
return 0;
}

/**
* Run an internal (Symfony) command.
*
* @param InputInterface $input Input object
* @param OutputInterface $output Output object
* @param array $config Configuration of command to run
*
* @return int
*/
protected function runInternalCommand(InputInterface $input, OutputInterface $output, array $config): int
{
$output->writeLn("Not implemented yet.");
return 0;
}

/**
* Display a menu or prompt for the provided configuration.
*
@@ -137,7 +167,10 @@ protected function displayOptions(InputInterface $input, OutputInterface $output
switch ($type) {
case 'menu':
return $this->displaySubmenu($input, $output, $config['contents'] ?? []);
case 'command':
case 'external-command':
return $this->runExternalCommand($input, $output, $config);
case 'internal-command':
return $this->runInternalCommand($input, $output, $config);
default:
$output->writeln("Unknown menu type '$type' with label '$label'");
return 1;