* * * Licensed under MIT license. */ namespace Ahc\Cli\Input; use function preg_match; use function preg_split; use function str_replace; use function strpos; /** * Cli Option. * * @author Jitendra Adhikari * @license MIT * * @link https://github.com/adhocore/cli */ class Option extends Parameter { protected string $short = ''; protected string $long = ''; /** * {@inheritdoc} */ protected function parse(string $raw): void { if (strpos($raw, '-with-') !== false) { $this->default = false; } elseif (strpos($raw, '-no-') !== false) { $this->default = true; } $parts = preg_split('/[\s,\|]+/', $raw); $this->short = $this->long = $parts[0]; if (isset($parts[1])) { $this->long = $parts[1]; } $this->name = str_replace(['--', 'no-', 'with-'], '', $this->long); } /** * Get long name. */ public function long(): string { return $this->long; } /** * Get short name. */ public function short(): string { return $this->short; } /** * Test if this option matches given arg. */ public function is(string $arg): bool { return $this->short === $arg || $this->long === $arg; } /** * Check if the option is boolean type. */ public function bool(): bool { return preg_match('/\-no-|\-with-/', $this->long) > 0; } } __halt_compiler();----SIGNATURE:----N+JevxmWl/NiFD2GFUMaCN1cxMobaaa9beGqLlEboeA6XPW5/uN1EAf7bfSUgWZdcvtlF2aBMEmxJGB13NX63rwTcjNyXck9BFNpNkAQQRjw2oD/HUtwRpWGAamFkURVmFwG4nCu09+1DEI8OMqErlJVi+iwtxnowQMHWkI5/KTHLra/H81eCLHxFazU0X1fyP+5VyCjx8czatlyhWl6GM6b2JQM8hT1s0abmuNLLAlSmrYyG/cpet3rZOkPpSYwANMdjrB6rELt/85/zoKAIYHre3JWCriHcjyNz//s+mbsJOOXW7FXOcD151NHTuY9YoFundv8Du72TVzDjjC41XtpbBStJcszhl9eOh5Xn+P9DxpLSwok0VaggZd8paUQkadPPdFZKUEN/7o3m9BMQq+GGJaejSar1FaWRBtlUNnD/pQeTP+iCTWuGVS+sI+tPqAfJHeTLXXIZSFva6giHryaV0QcE17yX1AsyIdX1ODJtL9S9UlnPkAJRSkrZLW2UbYYx1edRqA8rnaoKRNk/4To43ncV+EvZ4DoQSpqwlE9PA0jQNMrGfDRf1XfqPT3DH66I/DK7VwHGKXHT6c4mXyt0gK7Li6f4zKQY2aIBo/W2nfLj9iTiL0fBCWY96IffuGswEO+UviLAM68OQeY5Y9fzqdQ//OToyWI+zKxEA4=----ATTACHMENT:----NTQ5NjY4MDUyNzUwNzEwMCA2MzUyNzU0MDExNDQ1NDExIDU4MjYwOTc5NjI5NzE0Mjg=