PHPWarrior\Runner::parse_options PHP Method

parse_options() public method

Parse the options.
public parse_options ( )
    public function parse_options()
    {
        $getopt = new Getopt([['d', 'directory', Getopt::REQUIRED_ARGUMENT, 'Run under given directory'], ['l', 'level', Getopt::REQUIRED_ARGUMENT, 'Practice level on epic'], ['s', 'skip', Getopt::NO_ARGUMENT, 'Skip user input'], ['t', 'time', Getopt::REQUIRED_ARGUMENT, 'Delay each turn by seconds'], ['L', 'locale', Getopt::REQUIRED_ARGUMENT, 'Specify locale like en_US'], ['h', 'help', Getopt::NO_ARGUMENT, 'Show this message']]);
        try {
            $getopt->parse();
        } catch (\Exception $e) {
            echo $e->getMessage() . "\n";
            exit;
        }
        if ($getopt->getOption('h')) {
            echo $getopt->getHelpText();
            exit;
        }
        if ($getopt->getOption('d')) {
            Config::$path_prefix = $getopt->getOption('d');
        }
        if ($getopt->getOption('l')) {
            Config::$practice_level = $getopt->getOption('l');
        }
        if ($getopt->getOption('s')) {
            Config::$skip_input = true;
        }
        if (!is_null($getopt->getOption('t'))) {
            Config::$delay = $getopt->getOption('t');
        }
        // get locale from $LANG like en_US.UTF8
        list(Config::$locale) = explode('.', getenv('LANG'));
        if ($getopt->getOption('L')) {
            Config::$locale = $getopt->getOption('L');
        }
    }