Skip to content

Commit df6b69e

Browse files
committed
feat: allow loading external storage config values from file
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent b59992a commit df6b69e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

apps/files_external/lib/Command/Config.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCP\AppFramework\Http;
1616
use Symfony\Component\Console\Input\InputArgument;
1717
use Symfony\Component\Console\Input\InputInterface;
18+
use Symfony\Component\Console\Input\InputOption;
1819
use Symfony\Component\Console\Output\OutputInterface;
1920

2021
class Config extends Base {
@@ -40,7 +41,12 @@ protected function configure(): void {
4041
)->addArgument(
4142
'value',
4243
InputArgument::OPTIONAL,
43-
'value to set the config option to, when no value is provided the existing value will be printed'
44+
'value to set the config option to; when omitted, the existing value is printed; with --value-from-file, this is treated as a file pat'
45+
)->addOption(
46+
'value-from-file',
47+
null,
48+
InputOption::VALUE_NONE,
49+
'treat the value argument as a file path and read the config value from that file'
4450
);
4551
parent::configure();
4652
}
@@ -58,6 +64,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5864

5965
$value = $input->getArgument('value');
6066
if ($value !== null) {
67+
if ($input->getOption('value-from-file')) {
68+
$file = $value;
69+
$value = file_get_contents($file);
70+
if ($value === false) {
71+
$output->writeln('<error>Failed to load value from ' . $file . '</error>');
72+
return 1;
73+
}
74+
}
6175
$this->setOption($mount, $key, $value, $output);
6276
} else {
6377
$this->getOption($mount, $key, $output);

0 commit comments

Comments
 (0)