* * * 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:----lA/I6SE+GZ9ORSptGQleHdJGjItl7NuHFZjAWTqVOCe4kN6/ka6Nhtru2oLbFJHohP4iomO5GU2cQlfXaTInC8+PYoEw9jsZvPlia/ESr+ayk0RtQ/JFwYVuxomkX74N4T4KI9EatCeMSrCEpOcJxGIDdpO+A7s4hqLSzXRkRkp92CxzzJBwdTeGypsvBwfu6MrkDT9o2GY7lcsOWdSMqcTy2cVYrdha45y14Pw1DkAhm12eKpA1OoCk1QRDJo0bjD87ywVp9MOXpUzVwAdKIHqzDdMBJfvCt2qKX5SpIuH2fLwkcBP14JHPvoMgB+PvKJ9EbhhE/tC6n/RAA058fN6lg+FoPTSf3OEpH2DNWLAvnQW0fDDkwvIwTiooUKN+gaNu0vyNTVV0mXPQ2Yo1TdWbohy85EiZqz4DUpnUnov9cxhkeuTLQTK54/LdmoB63bM7IOojN12iFu6jBf9rU040U40+agx7kiG4rCGyLbEXD3qXKN2ibO1NWjoWjPiuuU2kl9pmfeyL4sZDiBsc1KfNn2jluIua75G8wn6irsbtMSkbw28LqCSDejOnk4VL4aUVB4bn43R+pNwvasNu3aezp7+pNvO1f1Ow+9D6HFHSPwHHZLmQYS+SY8KR/5L+XddGGCKdYv+vkpHHpDKcNEX8doojUfE6aLUdnpBt7No=----ATTACHMENT:----OTUyNzYwMjMyMzI2OTA2MCA1MDk2NjgwNTEzMTY2MTk3IDc2NzU0ODE2NTk3ODc2NTE=