From 97963dd82b433f7cb443ea1e4483e8dfbd836de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 7 Mar 2024 18:09:23 +0100 Subject: [PATCH] doc: add some explaination about the verbose option --- examples/run.php | 2 +- src/Console/Command/TaskCommand.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/run.php b/examples/run.php index 38b16da2..717ab0ab 100644 --- a/examples/run.php +++ b/examples/run.php @@ -12,7 +12,7 @@ use function Castor\run; #[AsTask(description: 'Run a sub-process and display information about it')] -function ls(): void +function ls(bool $verbose = false): void { $process = run('ls -alh && echo $foo', quiet: true, environment: ['foo' => 'ba\'"`r']); diff --git a/src/Console/Command/TaskCommand.php b/src/Console/Command/TaskCommand.php index cdc2077c..d55f1635 100644 --- a/src/Console/Command/TaskCommand.php +++ b/src/Console/Command/TaskCommand.php @@ -108,6 +108,10 @@ protected function configure(): void $taskArgumentAttribute->suggestedValues, ); } elseif ($taskArgumentAttribute instanceof AsOption) { + if ($name === 'verbose') { + throw new FunctionConfigurationException('You cannot re-define a "verbose" option. But you can use "output()->isVerbose()" in your code instead.', $this->function); + } + $mode = $taskArgumentAttribute->mode; $defaultValue = $parameter->isOptional() ? $parameter->getDefaultValue() : null;