* * * 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:----OWGuMZDPcTGRF5d9jGM3BUMKzlDH6//stfzAHrArGMcPQBVHAvDdmRYqbGcK7OpKeL3x8zp9I0rhdSEpTYVaSVVoY5Tn68xHBXOHCNqheuO+ed3UxeQ+hDlZ3e7DV0GtZxu6vIOcp8UIlo51YnGJwnQtRj6jtoggD2EvQZ9zEWLwU2NC9cpKghQ6D/IReFzlDtccUWArnR8y0Qq/ABLCsZ7hbK5jXRDx4WSdvcUm/VWYasHt31pddYSdKPvmky5wdDykPIRQynQxMm0xWQKOQP0dThIGdoOBK69e4LCCm/ktWpBeNfQT6Y3nj2ta1hNox4NaQk3JwDXnXK4C9ZdszSbF+PSvg/iCs4ZQv6Wo0HKJdko8Gcce0/0RbHQN0jGFQCo44EMOvc0TPMSEVXkl0Zz59TCRkNN7QAN+S5W7JD8RcnWSy5ZBVJPJ5xbDzlDKmHzQrTwmy9BFgyc2RC11HsHAfAYcn/mdiLaXwWKLGKkrhX3fH8JGYaGodJXkEY7MzHgJ6zUVQn/A0RqE7Rbr+aZrEjRngR7FMvUm7HFqxHsZRlQz/zflRr7R9Y4zkrd0qoupchxMPwaTkrboQ1fwKY6rDnhwZuAqKLdcsUW1/YDDgFfYph/Mn8T9Fh87KgtMGomJKuQt1ufWcuPt9jiTdTYGqx2TVncc3pPTwsGjeA0=----ATTACHMENT:----NjY5NjkzMDE0NzkwNDAwNCA2NzQ0MDM4MzI4MjcxMTcgMjcyODQwMDE4NDM4NjI3