# File raggle, line 1978
    def CLI::parse_cli_options(opts)
      ret = { 'mode' => 'view' }
    
      gopts = GetoptLong.new(
        ['--add', '-a',                             GetoptLong::OPTIONAL_ARGUMENT],
        ['--ascii', '-A',                           GetoptLong::NO_ARGUMENT],
        ['--config', '-c',                          GetoptLong::REQUIRED_ARGUMENT],
        ['--delete', '-d',                          GetoptLong::REQUIRED_ARGUMENT],
        ['--default-config',                        GetoptLong::NO_ARGUMENT],
        ['--diag',                                  GetoptLong::NO_ARGUMENT],
        ['--drb-server', '--drb',                   GetoptLong::NO_ARGUMENT],
        ['--edit', '-e',                            GetoptLong::REQUIRED_ARGUMENT],
        ['--export-opml',                           GetoptLong::REQUIRED_ARGUMENT],
        ['--find', '-f',                            GetoptLong::REQUIRED_ARGUMENT],
        ['--force',                                 GetoptLong::NO_ARGUMENT], 
        ['--help', '-h', '--usage',                 GetoptLong::NO_ARGUMENT],
        ['--import-opml',                           GetoptLong::REQUIRED_ARGUMENT],
        ['--invalidate', '-i',                      GetoptLong::REQUIRED_ARGUMENT],
        ['--list', '-l',                            GetoptLong::NO_ARGUMENT],
        ['--lock-title',                            GetoptLong::NO_ARGUMENT],
        ['--max',                                   GetoptLong::REQUIRED_ARGUMENT],
        ['--priority', '-p',                        GetoptLong::REQUIRED_ARGUMENT],
        ['--purge',                                 GetoptLong::NO_ARGUMENT],
        ['--refresh', '-r',                         GetoptLong::REQUIRED_ARGUMENT],
        ['--save-items',                            GetoptLong::NO_ARGUMENT],
        ['--server',                                GetoptLong::OPTIONAL_ARGUMENT],
        ['--sort',                                  GetoptLong::NO_ARGUMENT],
        ['--title', '-t',                           GetoptLong::REQUIRED_ARGUMENT],
        ['--unlock-title',                          GetoptLong::NO_ARGUMENT],
        ['--unsave-items',                          GetoptLong::NO_ARGUMENT],
        ['--update', '-U',                          GetoptLong::OPTIONAL_ARGUMENT],
        ['--url', '-u',                             GetoptLong::REQUIRED_ARGUMENT],
        ['--verbose', '-v',                         GetoptLong::NO_ARGUMENT],
        ['--version', '-V',                         GetoptLong::NO_ARGUMENT]
      )
    
      begin
        gopts.each do |opt, arg|
          case opt
            when '--add'
              ret['mode'] = 'add'
              ret['url'] = arg if arg && arg.size > 0
            when '--edit'
              ret['mode'] = 'edit'
              ret['id'] = arg.to_i
            when'--delete'
              ret['mode'] = 'delete'
              ret['id'] = arg.to_i
            when '--invalidate'
              ret['mode'] = 'invalidate'
              ret['id'] = arg.to_i
            when '--update'
              ret['mode'] = 'update'
              ret['id'] = (arg && (arg != 'all')) ? arg.to_i : 'all'
            when '--config':  $config['config_path'] = arg
            when '--force':   ret['force'] = true
            when '--list':    ret['mode'] = 'list'
            when '--title':   ret['title'] = arg
            when '--url':     ret['url'] = arg
            when '--refresh': ret['refresh'] = arg.to_i
            when '--version'
              puts "Raggle v#$VERSION"
              exit(0)
            when '--priority':      ret['priority'] = arg.to_i
            when '--purge':         ret['mode'] = 'purge'
            when '--sort'
              ret['mode'] = 'sort'
            when '--lock-title':    ret['lock_title?'] = true
            when '--unlock-title':  ret['lock_title?'] = false
            when '--save-items':    ret['save_items?'] = true
            when '--max'
              ret['max_items'] = arg.to_i
              ret['save_items?'] = true if ret['max_items'] > 0
            when '--unsave-items':  ret['save_items?'] = false
            when '--verbose':       $config['verbose'] = true
            when '--import-opml'
              ret['mode'] = 'import_opml'
              ret['opml_file'] = arg
            when '--export-opml'
              ret['mode'] = 'export_opml'
              ret['opml_file'] = arg
            when '--diag':          $config['diag'] = true
            when '--default-config'
              ret['mode'] = 'default_config'
            when '--ascii':         ret['ascii'] = true
            when '--server'
              if $HAVE_LIB['webrick']
                $config['run_http_server'] = true
                $config['http_server']['port'] = arg.to_i \
                  if $config['http_server'] && arg && arg.to_i > 0
              else
                die 'Missing WEBrick, can\'t run HTTP Server.'
              end
            when '--drb-server'
              if $HAVE_LIB['drb']
                $config['run_drb_server'] = true
              else
                die "Missing DRb, can't run DRb Server."
              end
            when '--find'
              ret['mode'] = 'find_feeds'
              ret['find_str'] = arg
            when '--help'
              CLI::print_usage
          end
        end
      rescue GetoptLong::InvalidOption 
        exit(-1)
      end
    
           
      # check options
      if ret['mode'] == 'add'
        ['url'].each { |val| # removed 'title' and 'refresh' for now
          unless ret[val]
            die "Missing '--#{val}'."
            exit(-1)
          end
        }
      elsif ret['mode'] == 'edit'
        unless ret['title'] || ret['url'] || ret['refresh'] ||
               ret.has_key?('lock_title?') || ret.has_key?('save_items?')
          die "Please specify a feed change to make."
        end
      end
    
      # return options
      ret
    end