mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
declare option as argument when value is required and no default option can be provided
This commit is contained in:
@@ -31,9 +31,13 @@ class module_console_fieldsDelete extends Command
|
||||
|
||||
$this->setDescription('Delete a documentation field from a Databox');
|
||||
|
||||
$this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||
// $this->addArgument('name', InputArgument::REQUIRED, 'Metadata structure ids for source');
|
||||
$this->addArgument('meta_struct_id', InputArgument::REQUIRED, 'Metadata structure id destination');
|
||||
$this->addArgument('sbas_id', InputArgument::REQUIRED, 'Databox sbas_id');
|
||||
|
||||
$this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||
// $this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||
//
|
||||
// $this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -41,14 +45,14 @@ class module_console_fieldsDelete extends Command
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
if ( ! $input->getOption('sbas_id'))
|
||||
if ( ! $input->getArgument('sbas_id'))
|
||||
throw new \Exception('Missing argument sbas_id');
|
||||
|
||||
if ( ! $input->getOption('meta_struct_id'))
|
||||
if ( ! $input->getArgument('meta_struct_id'))
|
||||
throw new \Exception('Missing argument meta_struct_id');
|
||||
|
||||
try {
|
||||
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||
$databox = \databox::get_instance((int) $input->getArgument('sbas_id'));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln("<error>Invalid databox id </error>");
|
||||
|
||||
@@ -56,7 +60,7 @@ class module_console_fieldsDelete extends Command
|
||||
}
|
||||
|
||||
try {
|
||||
$field = $databox->get_meta_structure()->get_element((int) $input->getOption('meta_struct_id'));
|
||||
$field = $databox->get_meta_structure()->get_element((int) $input->getArgument('meta_struct_id'));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln("<error>Invalid meta struct id </error>");
|
||||
|
||||
|
@@ -31,27 +31,31 @@ class module_console_fieldsMerge extends Command
|
||||
|
||||
$this->setDescription('Merge databox structure fields');
|
||||
|
||||
$this->addOption(
|
||||
'source'
|
||||
, 'f'
|
||||
, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
|
||||
, 'Metadata structure ids for source'
|
||||
, array()
|
||||
);
|
||||
$this->addArgument('source', InputArgument::REQUIRED, 'Metadata structure ids for source');
|
||||
$this->addArgument('sbas_id', InputArgument::REQUIRED, 'Databox sbas_id');
|
||||
$this->addArgument('destination', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Metadata structure id destination');
|
||||
|
||||
$this->addOption(
|
||||
'destination'
|
||||
, 'd'
|
||||
, InputOption::VALUE_REQUIRED
|
||||
, 'Metadata structure id destination'
|
||||
);
|
||||
// $this->addOption(
|
||||
// 'source'
|
||||
// , 'f'
|
||||
// , InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
|
||||
// , 'Metadata structure ids for source'
|
||||
// , array()
|
||||
// );
|
||||
|
||||
$this->addOption(
|
||||
'sbas_id'
|
||||
, 's'
|
||||
, InputOption::VALUE_REQUIRED
|
||||
, 'Databox sbas_id'
|
||||
);
|
||||
// $this->addOption(
|
||||
// 'destination'
|
||||
// , 'd'
|
||||
// , InputOption::VALUE_REQUIRED
|
||||
// , 'Metadata structure id destination'
|
||||
// );
|
||||
|
||||
// $this->addOption(
|
||||
// 'sbas_id'
|
||||
// , 's'
|
||||
// , InputOption::VALUE_REQUIRED
|
||||
// , 'Databox sbas_id'
|
||||
// );
|
||||
|
||||
$this->addOption(
|
||||
'separator'
|
||||
@@ -68,11 +72,11 @@ class module_console_fieldsMerge extends Command
|
||||
{
|
||||
$output->writeln("");
|
||||
|
||||
if ( ! $input->getOption('sbas_id'))
|
||||
if ( ! $input->getArgument('sbas_id'))
|
||||
throw new \Exception('Missing argument sbas_id');
|
||||
|
||||
try {
|
||||
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||
$databox = \databox::get_instance((int) $input->getArgument('sbas_id'));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln("<error>Invalid databox id </error>");
|
||||
|
||||
@@ -81,19 +85,19 @@ class module_console_fieldsMerge extends Command
|
||||
|
||||
$sources = array();
|
||||
|
||||
foreach ($input->getOption('source') as $source_id) {
|
||||
foreach ($input->getArgument('source') as $source_id) {
|
||||
$sources[] = $databox->get_meta_structure()->get_element($source_id);
|
||||
}
|
||||
|
||||
if (count($sources) === 0)
|
||||
throw new \Exception('No sources to proceed');
|
||||
|
||||
if ( ! $input->getOption('destination'))
|
||||
if ( ! $input->getArgument('destination'))
|
||||
throw new \Exception('Missing argument destination');
|
||||
|
||||
$separator = ' ' . $input->getOption('separator') . ' ';
|
||||
|
||||
$destination = $databox->get_meta_structure()->get_element($input->getOption('destination'));
|
||||
$destination = $databox->get_meta_structure()->get_element($input->getArgument('destination'));
|
||||
|
||||
$types = $multis = array();
|
||||
|
||||
|
@@ -31,11 +31,15 @@ class module_console_fieldsRename extends Command
|
||||
|
||||
$this->setDescription('Rename a documentation field from a Databox');
|
||||
|
||||
$this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||
$this->addArgument('name', InputArgument::REQUIRED, 'Metadata structure ids for source');
|
||||
$this->addArgument('meta_struct_id', InputArgument::REQUIRED, 'Metadata structure id destination');
|
||||
$this->addArgument('sbas_id', InputArgument::REQUIRED, 'Databox sbas_id');
|
||||
|
||||
$this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||
|
||||
$this->addOption('name', 'n', InputOption::VALUE_REQUIRED, 'The new name');
|
||||
// $this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||
//
|
||||
// $this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||
//
|
||||
// $this->addOption('name', 'n', InputOption::VALUE_REQUIRED, 'The new name');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -43,19 +47,19 @@ class module_console_fieldsRename extends Command
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
if ( ! $input->getOption('sbas_id'))
|
||||
if ( ! $input->getArgument('sbas_id'))
|
||||
throw new \Exception('Missing argument sbas_id');
|
||||
|
||||
if ( ! $input->getOption('meta_struct_id'))
|
||||
if ( ! $input->getArgument('meta_struct_id'))
|
||||
throw new \Exception('Missing argument meta_struct_id');
|
||||
|
||||
if ( ! $input->getOption('name'))
|
||||
if ( ! $input->getArgument('name'))
|
||||
throw new \Exception('Missing argument name');
|
||||
|
||||
$new_name = $input->getOption('name');
|
||||
$new_name = $input->getArgument('name');
|
||||
|
||||
try {
|
||||
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||
$databox = \databox::get_instance((int) $input->getArgument('sbas_id'));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln("<error>Invalid databox id </error>");
|
||||
|
||||
|
Reference in New Issue
Block a user