* * * 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:----SH2oSvMepEduqIogoYd3F3LjbHDmo6N1maBDX5I27QX8H8dPIT2W9Xh02maHyzYIPDFShVH3zYjLZdUzBDpro0nPD82ncvXgcVUvYRwwWJzD0MBOfFzwcJNUSrRtdzA+WgAr2yrRoUCrRjt0kSfSctKxPCMAOdGOMSV+4TkW9qHbxGAMdWJMuztcfPJQHe6FZbJJrqN6QjGhUjinLDegAcZZuOVLnPq0c96l6ncRLpZfRO410FSbsgFSFrAI6yfzw0mJt3AEMLaYSjsFrvciqxrOoiYWgnB7GK9v8BdeP8ygNoGHA76rsptE8/+zsFXw1bYX47tJPxU/9MBRpWhiHLf7IaqGxoaA2x9V8b6MaNpuadygL2Svo46MyQJDRY31YMhwSppVY3M55DUi885WPBnckwBVzgF1FBQfoYvPrENuSpuMF7TkKElUesJh5EaBmSoKb9nEgdJWYoDhYTd/l1+/HOSPW6hkS+5eKkhx4a3tnNm8UnlZmF8zb5vpYIL5oMyFas2Zg6ZgwFZWDkZVPb+16rKhlZBbTGnOZLYjQ8MPZ5jM/sWU5Ww3uJjj2HhsagnrXfPL6zDxsiTu1bqQD7bkzJzCwwSjecuI7rwQKK8YT51fnBOnpjCZ2Sm2KPpidjKPYvGkwSJdR2Fuu0EP8xRFMrGrgj5DusPFhcjdBy4=----ATTACHMENT:----NTA1Mjc1NjAxNTMzODkzNSA0NDA1ODMzNDMwMzg3NDU4IDU2Njk4MTEwMjYxODM0Njg=