* * * 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:----kXolk1eY16oE8omCV3j8a4Rf3ur+p30n097IdxET8Eygc1utpkvopO/jwEFRaXqL2DtfLVX3Core12l0iIf8q+h4iBH+45vfuxd4o5KNit9tobHJ9/12IG7rYwHL81PRPTW0u+0AlyudLbs+3ElnyTtW2FNIvZu4vC1W0qIZLb3Kqlu3aJh/kwOh5pvF+wpgLMDxesvph7hBY7wTqItauqyacptDN3LJawBEz+kv8UJ0g9XJspjc2v47RQE4yrxerhC3PMYFFG6rmOakgeDFcLJ7xfNIWwX5AY6Bv4QVv9LpzaZlSHkQd9niiawSy7Tfaqb/Wxq17RGkWEynvcd+2OB9uOJNa+jQFBxzARR3+CHUPxTHHZvZPWOG0ISxdFzOOSaxGDUAn3CG+BBVDf2pFtO3CSF4RP8o5SqE4x9HQpIPENhBaNCrmbd4H/Z1pMnspY5ZYw5MMX4FcsQ3NGt4wPDyJhnb75uk/IWhUZs+wZTa8id8zDGbExXb/MwZFdv0KKDCL9VGgXseaCUT636f9oXIKNFmiiS4UfTyeY53u0Rn4186v6xSphSzlOzfTcn2UyS/ICFWgFAo2D3zP/pScPuK/VxeVDVkCmj/cCWdFEbMdRPR9xxr6XfWmiqjzGi1Pb0Xf2mlI8e9AFD3uxFR9FPtI52PUieeU8tbnVdmxms=----ATTACHMENT:----NjAzNjE0ODI5NDE0MjQyMCA4NzEwNzY1MTM2NzY5MTc3IDg5ODIwODQ3NDQ0NjU4MjA=