Skip to content

Commit

Permalink
feat: Add reserved options in a new OCP class so that applications kn…
Browse files Browse the repository at this point in the history
…ow about them

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Jul 4, 2024
1 parent 9baf8fe commit 612088b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/Listener/BeforeMessageLoggedEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace OC\Core\Listener;

use OCP\Console\ReservedOptions;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
Expand Down Expand Up @@ -54,10 +55,10 @@ public static function setup(): void {
$argv = $_SERVER['argv'];
$level = 0;
foreach ($argv as $key => $arg) {
if ($arg === '--debug-log') {
if ($arg === '--'.ReservedOptions::DEBUG_LOG) {
unset($argv[$key]);
} elseif (str_starts_with($arg, '--debug-log-level=')) {
$level = (int)substr($arg, strlen('--debug-log-level='));
} elseif (str_starts_with($arg, '--'.ReservedOptions::DEBUG_LOG_LEVEL.'=')) {
$level = (int)substr($arg, strlen('--'.ReservedOptions::DEBUG_LOG_LEVEL.'='));
unset($argv[$key]);
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
'OCP\\Config\\BeforePreferenceDeletedEvent' => $baseDir . '/lib/public/Config/BeforePreferenceDeletedEvent.php',
'OCP\\Config\\BeforePreferenceSetEvent' => $baseDir . '/lib/public/Config/BeforePreferenceSetEvent.php',
'OCP\\Console\\ConsoleEvent' => $baseDir . '/lib/public/Console/ConsoleEvent.php',
'OCP\\Console\\ReservedOptions' => $baseDir . '/lib/public/Console/ReservedOptions.php',
'OCP\\Constants' => $baseDir . '/lib/public/Constants.php',
'OCP\\Contacts\\ContactsMenu\\IAction' => $baseDir . '/lib/public/Contacts/ContactsMenu/IAction.php',
'OCP\\Contacts\\ContactsMenu\\IActionFactory' => $baseDir . '/lib/public/Contacts/ContactsMenu/IActionFactory.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Config\\BeforePreferenceDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/Config/BeforePreferenceDeletedEvent.php',
'OCP\\Config\\BeforePreferenceSetEvent' => __DIR__ . '/../../..' . '/lib/public/Config/BeforePreferenceSetEvent.php',
'OCP\\Console\\ConsoleEvent' => __DIR__ . '/../../..' . '/lib/public/Console/ConsoleEvent.php',
'OCP\\Console\\ReservedOptions' => __DIR__ . '/../../..' . '/lib/public/Console/ReservedOptions.php',
'OCP\\Constants' => __DIR__ . '/../../..' . '/lib/public/Constants.php',
'OCP\\Contacts\\ContactsMenu\\IAction' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IAction.php',
'OCP\\Contacts\\ContactsMenu\\IActionFactory' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IActionFactory.php',
Expand Down
24 changes: 24 additions & 0 deletions lib/public/Console/ReservedOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\Console;

/**
* @since 30.0.0
*/
final class ReservedOptions {
/**
* @since 30.0.0
*/
public const DEBUG_LOG = 'debug-log';
/**
* @since 30.0.0
*/
public const DEBUG_LOG_LEVEL = 'debug-log-level';
}

0 comments on commit 612088b

Please sign in to comment.