1515use OCP \AppFramework \Http ;
1616use Symfony \Component \Console \Input \InputArgument ;
1717use Symfony \Component \Console \Input \InputInterface ;
18+ use Symfony \Component \Console \Input \InputOption ;
1819use Symfony \Component \Console \Output \OutputInterface ;
1920
2021class 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