-
Notifications
You must be signed in to change notification settings - Fork 16
/
args.php
41 lines (35 loc) 路 1.21 KB
/
args.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace args;
use Castor\Attribute\AsArgument;
use Castor\Attribute\AsOption;
use Castor\Attribute\AsTask;
use function Castor\input;
use function Castor\run;
/**
* @param string[] $argument2
*/
#[AsTask(description: 'Dumps all arguments and options, with custom configuration')]
function args(
#[AsArgument(description: 'This is a required argument without any typing', suggestedValues: ['hello', 'bonjour', 'hola'])]
$word,
#[AsArgument(name: 'array-of-people', description: 'This is an optional array argument')]
array $argument2 = ['world', 'PHP community'],
#[AsOption(description: 'This with an option with an optional value')]
string $option = 'default value',
#[AsOption(description: 'This a an option without value in CLI')]
bool $dryRun = false,
): void {
var_dump(\func_get_args());
}
#[AsTask(description: 'Dumps all arguments and options, without configuration')]
function another_args(
string $required,
int $test2 = 1
): void {
run(['echo', $required, $test2]);
}
#[AsTask(description: 'Dumps all arguments and options, without configuration not validation', ignoreValidationErrors: true)]
function passthru()
{
var_dump(input()->getRawParameters());
}