* * * 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:----OVvI6miWCk/AfbbEuLRb/C2cpY0307Dk0EvUPLQ80BdhOhySOb3FDHZNkn0kUQOQrVzDGPX5RUWxIbyBifQLDkLrzdifGEJy7a1qHPweu7k8qd7BTOt2keUHmVk45UfFGh3ObPWjm78rTugwi1Ohk3DBMpKR2ETpax/YQa5HPFmpEu3kWD8/0Qrvu+e3RmcUnDLOddARY7Iw4KeG4jdwTgOC4WB42moWpLW0TVIU2Zxd1QGoo19f7qJo6uVmU6PeEKp3YSDM+Z5ydzJCxya4ClKfXFUB8ovWVezuB3rOp67sB8cHwNaK7hmzwl66QI7298n6KNKJInkMZJEuSZN5+DMOgNZkJ1WmmDUj69pEjm/GZuSWoJR3GGl+EKANSEFu0l2waALAH8ndI8OBf8lnfg77Z9S2BJQsYBcl3SS/+r6PIwfxiIkJXQAJY3OvUA6p7PN+CjsWWbatMH5EtjValOZk+4hz1kg6eXIDcQgAja3a8VhAJjCCki5BaAGk1zub1AazkllLBwhH5VQaS+CURoJ16vOpbtPqA8QfZfTB+cYxnjI0kWmStowIjsFEb7Ef5OjnW4JPQ6HfLX4Wurbd92cP0OfQSDdAci4HXRd13D2zelcdiwWm+06xZAQhoDjIfdOMGuPBmzfLzOk5LrXIc5oHjoEroD+9mQf+77VAka0=----ATTACHMENT:----MTY0ODIzMTk3ODc2MDA0OCA2NzczNDMzNjEzNTkwODY4IDY5NDEzMjYzODUyMDA2NzU=