* * * 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:----R33cqH+6akrasXMv/QkVmT4iZhakul6auMJRADvXLKeP08EWmjstB3C1CeOe1nTnmBLs9WKTU0X1BL1bwI36ymRNyO2QCzT3kplg3nQ93VV18eb+Yqi1oFGcMdipAZODgL0/tlEYt9+hw3s9CVnuw4LlPaZfR39Gp+Dqc2957Y9/ID25VZt/lOIRoLoFuHiI2+GFdy6ZBpDnkgMJR9OJljf7Z0Xo0f7SmRaNIKa+7w6DxWYv3/5eJLE5H9Jldh1uWv+YIXl+XQEI47nOqBwJJ2m6e44qG7jQzJZClQhik7R0xVQ2M/qTvAsyjL1wMz7V7J0bpbeZqKh5B7lo2b9p/FTq3D68kpAMpGz0bFHBn36l5ZsZzFM3MPkjIJ+sOz/Vai2odd3UXzk5x0Ep1My/osSHbvl48KkOKqRIlF8anahsiBDvqMgiccTjyLHQf0b+GZV0iRvthtGRZztdGHzYCB3ppTGEBOa4VorhIbBmhTBW7qYIgr08e4jELTkkvbWyQsdlcxDBVdQQ6G27w/fEy2fQsB3CZ9uzgerflTFc2caz22Z+DRkbTMSQDVK8xLVoSpkjVHt788+KEB0vVbvGg9nGY+Nh75+CAn/UJc5YzSVG/7tFMtqGEeGyWPMikUJklLQB6gdnNiRyUSl4XCXr707cin5mI0kHrZ165K3qslc=----ATTACHMENT:----MTMyODkwMzUzNjk2OTc4MyA5MDAxNzQ2NzEyMTcyMzc2IDcxODM2MDcyOTg0MTgwMjM=