* * * 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:----HXIJcuIc/dKCZVCYc0KZwZ1zN0BntiFLyvxXcIpaK9lv5Xi0yRj7Hs7/FOcmuh+/Kb8vhhe4QSYvy50w7pQ4PwRbtjEPP/0EwfJfppiBw/ws+WnyMhCLHuzzKP7S/ScuUyDcFZ0RNNajkPPovaMnHIVifBTqRjZGQhIJr6jt40YVET1owrAMm9cAPnv7KmJUErEhfM4QXzNyneE7B11Y8h5kuBitx+rX6E0S4UehIC7hqWTf6Xt5eP4X4FQ2lE2wYlG6X4XC+lyIBWh//9p3cLhcUfoFTLE9y4ofvT3QmOM/Xu6wwtH750qOrRCPpZN1D2Tdu35jl2Kfoxp06Y7cmVC8GHcUbPq94gBLqb94dJ+R1+Ut8IBaIbB0XcyaQNS+pEjCQmcECYtOWFD2Ni2waYQjxsNwQ1NkL2FsSCbspCKnSoWvxBXZkoWmTnUD0ChCQ8cW1LGEeIyOBaJgxk72SF9ZViM+hXv/XkQEevsp85MGH5eSOYvRG8/NQriUvTFia8FlWtbKwLQxwGm2OTMWxqn/KxB0XRyT/lZjapqDoKSuHnMV3RZE79gmbAIzXS39IShgn7XJeVVx47Wwm3DN5EDxuaolhTSlhcIqckwSNQ0sH2gDhl/LHazM2juN+rF4B50EW1qdSSq7SRjmnr7i2n7E8zBu59ynePeqOsmrSlY=----ATTACHMENT:----MTkzNzk0MzU5MzUxMjE5OSAyNTgwNDYwNDUyMDQxMDMxIDU0ODI1MTA2OTQ1NzE2MjU=