Parse command line options.

def parse_options(self, args, depth=0):
        """Parse command line options.
        """
        style_names = tuple(self.defaults.known_styles)
        style_opts = tuple('--'+x for x in style_names)

        try:
            options, remaining_args = getopt.gnu_getopt(args, 'b:c:hls:v',
                ('help', 'style=', 'version', 'list-styles', 'browser=',
                 'config-file=') + style_names)
        except getopt.GetoptError as e:
            err_exit('viewdoc: %s\n%s' % (e.msg, USAGE))

        for name, value in options:
            if name in ('-s', '--style'):
                self.styles = self.defaults.known_styles.get(value, '')
            elif name in style_opts:
                self.styles = self.defaults.known_styles.get(name[2:], '')
            elif name in ('-b', '--browser'):
                self.browser = value
            elif name in ('-l', '--list-styles'):
                self.list = True
            elif name in ('-h', '--help'):
                msg_exit(HELP)
            elif name in ('-v', '--version'):
                msg_exit(VERSION)
            elif name in ('-c', '--config-file') and depth == 0:
                self.reset_defaults(expanduser(value))
                return self.parse_options(args, depth+1)

        if len(remaining_args) > 1:
            err_exit('viewdoc: too many arguments\n%s' % USAGE)

        if not isfile(self.defaults.filename) and depth == 0:
            self.write_defaults()
            return self.parse_options(args, depth+1)

        if self.defaults.version < CONFIG_VERSION and depth == 0:
            self.upgrade_defaults()
            return self.parse_options(args, depth+1)

        if self.list:
            self.list_styles()

        return remaining_args