* * * 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:----Hlot38FuGpr/Ek6QV+qB6llQYiwy9txWpjJm7upfw/NIejU/zq6sv1YZ9vVnKn09FYZhaT2xGg/oJHuHhhTV85rmHtUYlLoXthdl2ms5p0jzGv3fOA+sus7mmOB4z4jfJDFozD4Vw8+kpYirYS+zG7E3wHLMmwMkCWp8Tth3ZFqVXBjDtIt49FbWivHPIMezCp34lzRM57URgcMWenhCdWJi4lbwMYhFSG6LsYYZ2NKTqE2I0F6ljrS8eBjHKKVAf7VA9TqqB+zXvAP+4XJ3BYbpMHxrVPBuubn1qDdABzbfenDKn5t2MLyTTmIk3PsT9mgAevOkT/MzrUymZMKbG67cvsUwusodiemG41wZVIOKjjhXgf0M9G0tCe7WmUnAyXc7Z+bnvXLqLA3FsfVaOCf6+0bYJNwyLCDiJ20Gi0HuKKtw2BfjGLTDWkjF9bkDF6eSpz79wxsSTeKNDOuYYVB3qMVVY2N31JBDZACPROnpuS47ecbleQhyJiJXiL9FKe+BQrnfIHdA+v5NJw0wslWHHwg2Yb0c1/aMoJxHRasFgAZApgWKtVBElbyHA7PHOg9GFeBhFvp/h7716S9cvaH+1L1g1PMz9RbAc6NLdfsUpMT39M/y9S6t85DlhZNS4yHRG7usKneMlBcfCqFS737t596Oq6dwWWeoRs+JklE=----ATTACHMENT:----MTQ4NjcyMjk5MzE2NDY3NiA2MzYxNzA5NjY2MTI2MzEwIDM1MDQ4Mzg1NzkxMDMzMDA=