public static function getopts($options)
    {
        $opts = getopt(implode('', array_keys($options)), $options);

        $result = array();
        foreach ($options as $short => $long) {
            $short = trim($short, ':');
            $long = trim($long, ':');

            if (isset($opts[$short])) {
                $result[$long] = $opts[$short];
            } elseif (isset($opts[$long])) {
                $result[$long] = $opts[$long];
            }
        }

        return $result;
    }