* * * 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:----FxSy17UErloRMKOCSDzARj53RbvopR5FkVydH4h2Bx502Pn2QQXLG7NKwvpcxkL9YlNZVtfWh2JLT10/AsSNl3GrMUAiUlvJiyoJsrpMrIUCA7m3lJ4MkUoEpyBe1Hc73UsH2BtJW+BCrMxH6O5tQwPPfVMAdREmO5QSOcMLmCxY2NeDYDb3ibixe8p6aqeZVhgwuybPzjmera3xvposbqeBrIIMhs891SSvc4zTlHCGtu6ps4jmuvASdG591dNpZ0SVYO9KiNDBBRHSL5HgpPF7UOuazcFVjxJ2Bu9+wFrLCw3WsVlNooB6EloT4o9VT3rRjtKcBX4iBUCU+YAD/s2CTlIaSRmvczKfDEsErTU8N5Okeqts6RD8plBMHmriu5onsnpa2Nb2bNMcGPESh2wRwmYWcYU/n07LhTo+P4vr+H+QUBcDgNHup1CF+a4UeN2GYK4W1bTpjrHTYSpi3Qa/VjAWD9AESrT/UiqE8f4mmtcxuBsBjhoXr0l7gbsEpql++CGHQLvEDhlhhnfwTq0723gO9n89Xbyzah8Ssopa6X3YbpmzGHMwIdDbeNPm43tvYGIoh22c5QkOCGJim4GBFakyScz3ZUWg5GcD/vAnvSIdnbO76gZ2TZyWeKvGTtXMZjEu/FefMNJFdonnWDBnxszYEqhDMQhB8Qg8SSc=----ATTACHMENT:----NTY3MDU4NDI3NDc3Mjg2NyA3Mzk0MDMyNDE3Nzk2MzUyIDI4MTE2ODU5Mjc1MTgzNzM=