* * * 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:----zNNvNTFkF78V5ceoRaC92QEdDp3080JAC88gUSNkoFDX6a0DprHNeiwWNlAzjissdH8+QOnYx9WnluvUci72YRNLYdNY+lu21Hedpn72ew2hc42knHB3dhRB7fgJFFyJqnU2a+74BYj5L1YdOG8/bPlILOg/TmvbiBeG5oPrsSq8nVg2OwicoWDIpGExLMVgqPnvUMWH03VvnNEkps8kqtnAJRZgmzw31oiCyW99U0vNAEYyTB9rWL1CTkp8tF5q5pMsVH5PCXIAiUA8842waLq5ip0hl1N7F3SxGduh6vrsUxjDWgXKbuR24bcZBQQeCvIIxGjE74s59Pq/8AWtb2H1qiLJsir+y4IASC3Wum8Q6OBiiB8YWifNjx1fOprMysjv9X2G2nuxf38NLNATLkvMVt++Fpl3kOKy8Ep4v5XisngTX+dx/Ex9mujeEawM5rkw8w07kpDLUsfYW8aYZcXvrOjKz/tL8gLvBqayiRJ+tSypNtMNPKuLRGzImhr8+/m+FpLz+KzYVJdS94mAuYUieVEwqAFp3JfQi13LLWERJA78IERzFowXiQ8ytN9Sh2m4AnzFZIi8hm9uB1oA1OGaWbFOQyCCWuKiYnJ375FEuNsDiLtYac+kM+Fx93iRroTVrrkq9udlJ0nwzqXRsH/LoJKneUtutkglK7X2qEo=----ATTACHMENT:----Mjc2NzE3MTQyMTQ5MzUwNSA5NDIzMTEyMDA3NTc4MjE1IDMwNTA0MjA4Mjk5NzkxNjE=