1: <?php declare(strict_types=1);
2:
3: namespace Salient\Cli;
4:
5: use Salient\Contract\Cli\CliOptionType;
6: use Salient\Contract\Cli\CliOptionValueType;
7: use Salient\Contract\Cli\CliOptionValueUnknownPolicy;
8: use Salient\Contract\Cli\CliOptionVisibility;
9: use Salient\Core\AbstractBuilder;
10:
11: /**
12: * A fluent CliOption factory
13: *
14: * @method $this name(string|null $value) The name of the option (ignored if not positional; must start with a letter, number or underscore, followed by one or more letters, numbers, underscores or hyphens)
15: * @method $this long(string|null $value) The long form of the option, e.g. "verbose" (ignored if positional and name is given; must start with a letter, number or underscore, followed by one or more letters, numbers, underscores or hyphens)
16: * @method $this short(string|null $value) The short form of the option, e.g. "v" (ignored if positional; must contain one letter, number or underscore)
17: * @method $this valueName(?string $value) The name of the option's value as it appears in usage information
18: * @method $this description(?string $value) A description of the option
19: * @method $this optionType(CliOptionType::* $value) The option's type
20: * @method $this valueType(CliOptionValueType::* $value) The data type of the option's value
21: * @method $this allowedValues(array<string|int|bool|float>|null $value) The option's possible values, indexed by lowercase value if not case-sensitive
22: * @method $this unknownValuePolicy(CliOptionValueUnknownPolicy::* $value) The action taken if an unknown value is given
23: * @method $this required(bool $value = true) True if the option is mandatory (default: false)
24: * @method $this multipleAllowed(bool $value = true) True if the option may be given more than once (default: false)
25: * @method $this unique(bool $value = true) True if the same value may not be given more than once (default: false)
26: * @method $this addAll(bool $value = true) True if "ALL" should be added to the list of possible values when the option can be given more than once (default: false)
27: * @method $this defaultValue(array<string|int|bool|float>|string|int|bool|float|null $value) Assigned to the option if no value is given on the command line
28: * @method $this nullable(bool $value = true) True if the option's value should be null if it is not given on the command line (default: false)
29: * @method $this envVariable(string|null $value) The name of a value in the environment that replaces the option's default value (ignored if positional)
30: * @method $this delimiter(?string $value) The separator between values passed to the option as a single argument
31: * @method $this valueCallback((callable(array<string|int|bool|float>|string|int|bool|float): mixed)|null $value) Applied to the option's value as it is assigned (see {@see CliOption::$ValueCallback})
32: * @method $this visibility(int-mask-of<CliOptionVisibility::*> $value) The option's visibility to users
33: * @method $this inSchema(bool $value = true) True if the option should be included when generating a JSON Schema (default: false)
34: * @method $this hide(bool $value = true) True if the option's visibility should be {@see CliOptionVisibility::NONE} (default: false)
35: * @method CliOption load() Prepare the option for use with a command
36: *
37: * @api
38: *
39: * @extends AbstractBuilder<CliOption>
40: *
41: * @generated
42: */
43: final class CliOptionBuilder extends AbstractBuilder
44: {
45: /**
46: * @internal
47: */
48: protected static function getService(): string
49: {
50: return CliOption::class;
51: }
52:
53: /**
54: * @internal
55: */
56: protected static function getTerminators(): array
57: {
58: return [
59: 'load',
60: ];
61: }
62:
63: /**
64: * Bind the option's value to a variable
65: *
66: * @param mixed $variable
67: * @return static
68: */
69: public function bindTo(&$variable)
70: {
71: return $this->withRefB(__FUNCTION__, $variable);
72: }
73: }
74: