* * * 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:----i28bPDdO/yb7DhNVERyINx4ucRo3CSTL4c12nqua8gplWF1bfFgXP7YabE4W/z/wer8hUOI35N/raqBmprfnhLsq19kTOoDGMGG4DiQHzhCoceuYRMxyTce9OXpxjiHtEe2xPOvejzSd8Thyj2FRcSTShUltLn3jiqcZemRD9nyDT1N3Q6cElrMJNvUdicWj0SEYlsIW3G7yCWFUYcy1VgQCthx//PpZayDmLkROJ8F8K1WH/bBXn8LhaXJJeurv6GGIBsNWyHk4WpAk6/YRVPtL3XRExcUhtKlzACMGrw1Q0Y3MCkjfC3NSRyZk0NVnbI485fLkuwIqG2jCN5k3jkq579Uc+lG7rQU9fuy3i7Q9gVAOWULmd5LZZQQQDvu96ifh0FZTuo5cEvNzoKqtGmQ/zFRxMDkcJ7/M7O2jtDN5iMehmKh4FGJ71aGGa2mZLgErNThTN2CMPaiDpYpCJQiJQvm3CsbjWiUm6r3G03nPQfuAQVS0Q971DuT6+1i4oourphfNSrTa9d3vGGI3h9CoCFi/lRKJsiXFnFth4g0Ns8r3lKRfiN7pVQ7YEY9arm++tynF8QqAjfB35Vm1JUg64d3PIoCMqKKR7uKfClCzhVCLXv0K3jviDuPUfv/2YAaKwNuF+juRd9uybFttgKUMFQrBSwDbKDNfvZ2BEcs=----ATTACHMENT:----NDE4NzQ5MDkyMzE4ODcwOCA2MDY5MTIzMDM3MTcxMzAzIDE1NDY2MTQ3NTQ5NTgwMzU=