// ExtractOptionalFilters returns the first found OptionalFiltersOption from the
// given variadic arguments or nil otherwise.
426248
func ExtractOptionalFilters(opts ...interface{}) *opt.OptionalFiltersOption {
	for _, o := range opts {
		if v, ok := o.(*opt.OptionalFiltersOption); ok {
			return v
		}
	}
	return nil
}
295093
func ExtractAnalytics(opts ...interface{}) *opt.AnalyticsOption {
	for _, o := range opts {
		if v, ok := o.(*opt.AnalyticsOption); ok {
			return v
		}
	}
	return nil
}
291179
func ExtractEnableRules(opts ...interface{}) *opt.EnableRulesOption {
	for _, o := range opts {
		if v, ok := o.(*opt.EnableRulesOption); ok {
			return v
		}
	}
	return nil
}
955414
func Extract(fileName, targetDir string, options *ExtractOptions) error {
	if options == nil {
		options = &ExtractOptions{}
	}

	reader, err := newReader(fileName)
	if err != nil {
		return err
	}

	defer reader.Close()

	if err := os.MkdirAll(targetDir, os.ModePerm); err != nil {
		return err
	}

	// To improve performance the filters are prepared before.
	filters := prepareFilters(options.Filters)

	for {
		err := reader.Next()
		if err == io.EOF {
			return nil
		}
		if err != nil {
			return err
		}

		// Removes the last slash to avoid different behaviors when `header.Name` is a folder
		targetFileName := filepath.Clean(reader.header.Name)

		// Check if we have to extact the current file based on the user filters
		if !optimizedMatches(targetFileName, filters) {
			continue
		}

		// If FlatDir is true we have to extract all files into root folder
		// and we have to ignore all sub directories
		if options.FlatDir {
			if reader.header.Typeflag == tar.TypeDir {
				continue
			}
			targetFileName = filepath.Base(targetFileName)
		}

		// If `targetFileName` is an absolute path we are going to extract it
		// relative to the `targetDir`
		targetFileName = path.Join(targetDir, targetFileName)

		if err := reader.Extract(targetFileName, options.NoOverride); err != nil {
			return err
		}
	}
}
989210
func getAllOptions() string {
	options := ""
	for _, o := range validOptions {
		options += fmt.Sprintf("    <yellow>-%s --%-8s</yellow>    %s\n", o.short, o.long, o.description)
	}
	return options
}
952085
func getParserAndOptions(options GlobalOptions) (parsers.Parser, interface{}) {
	var parser parsers.Parser
	var opts interface{}
	switch options.Reqs.ParserName {
	case "regex":
		parser = &regex.Parser{}
		opts = &options.Regex
		opts.(*regex.Options).NumParsers = int(options.NumSenders)
	case "nginx":
		parser = &nginx.Parser{}
		opts = &options.Nginx
		opts.(*nginx.Options).NumParsers = int(options.NumSenders)
	case "json":
		parser = &htjson.Parser{}
		opts = &options.JSON
		opts.(*htjson.Options).NumParsers = int(options.NumSenders)
	case "keyval":
		parser = &keyval.Parser{}
		opts = &options.KeyVal
		opts.(*keyval.Options).NumParsers = int(options.NumSenders)
	case "mongo", "mongodb":
		parser = &mongodb.Parser{}
		opts = &options.Mongo
		opts.(*mongodb.Options).NumParsers = int(options.NumSenders)
	case "mysql":
		parser = &mysql.Parser{
			SampleRate: int(options.SampleRate),
		}
		opts = &options.MySQL
		opts.(*mysql.Options).NumParsers = int(options.NumSenders)
	case "postgresql":
		opts = &options.PostgreSQL
		parser = &postgresql.Parser{}
	case "arangodb":
		parser = &arangodb.Parser{}
		opts = &options.ArangoDB
	case "csv":
		parser = &csv.Parser{}
		opts = &options.CSV
		opts.(*csv.Options).NumParsers = int(options.NumSenders)
	case "syslog":
		parser = &syslog.Parser{}
		opts = &options.Syslog
		opts.(*syslog.Options).NumParsers = int(options.NumSenders)
	}
	parser, _ = parser.(parsers.Parser)
	return parser, opts
}
890458
func ExtractReferers(opts ...interface{}) *opt.ReferersOption {
	for _, o := range opts {
		if v, ok := o.(*opt.ReferersOption); ok {
			return v
		}
	}
	return nil
}
793781
func ExtractOptionalWords(opts ...interface{}) *opt.OptionalWordsOption {
	for _, o := range opts {
		if v, ok := o.(*opt.OptionalWordsOption); ok {
			return v
		}
	}
	return nil
}
210564
func ExtractFacetingAfterDistinct(opts ...interface{}) *opt.FacetingAfterDistinctOption {
	for _, o := range opts {
		if v, ok := o.(*opt.FacetingAfterDistinctOption); ok {
			return v
		}
	}
	return nil
}
1028421
func ExtractAttributesForFaceting(opts ...interface{}) *opt.AttributesForFacetingOption {
	for _, o := range opts {
		if v, ok := o.(*opt.AttributesForFacetingOption); ok {
			return v
		}
	}
	return nil
}
1059053
func ExtractAllowTyposOnNumericTokens(opts ...interface{}) *opt.AllowTyposOnNumericTokensOption {
	for _, o := range opts {
		if v, ok := o.(*opt.AllowTyposOnNumericTokensOption); ok {
			return v
		}
	}
	return nil
}
1192783
func ExtractTypoTolerance(opts ...interface{}) *opt.TypoToleranceOption {
	for _, o := range opts {
		if v, ok := o.(*opt.TypoToleranceOption); ok {
			return v
		}
	}
	return nil
}
982280
func ExtractExplain(opts ...interface{}) *opt.ExplainOption {
	for _, o := range opts {
		if v, ok := o.(*opt.ExplainOption); ok {
			return v
		}
	}
	return nil
}
276114
func ExtractCustomRanking(opts ...interface{}) *opt.CustomRankingOption {
	for _, o := range opts {
		if v, ok := o.(*opt.CustomRankingOption); ok {
			return v
		}
	}
	return nil
}
604149
func KeyFilter(key string, f Filter) Option {
	return func(ec *Envcfg) {
		ec.filters[key] = f
	}
}
1221718
func ExtractCreateIfNotExists(opts ...interface{}) *opt.CreateIfNotExistsOption {
	for _, o := range opts {
		if v, ok := o.(*opt.CreateIfNotExistsOption); ok {
			return v
		}
	}
	return nil
}
445350
func (d defaultPathProcessor) ExtractParameters(r *Route, _ *WebService, urlPath string) map[string]string {
	urlParts := tokenizePath(urlPath)
	pathParameters := map[string]string{}
	for i, key := range r.pathParts {
		var value string
		if i >= len(urlParts) {
			value = ""
		} else {
			value = urlParts[i]
		}
		if strings.HasPrefix(key, "{") { // path-parameter
			if colon := strings.Index(key, ":"); colon != -1 {
				// extract by regex
				regPart := key[colon+1 : len(key)-1]
				keyPart := key[1:colon]
				if regPart == "*" {
					pathParameters[keyPart] = untokenizePath(i, urlParts)
					break
				} else {
					pathParameters[keyPart] = value
				}
			} else {
				// without enclosing {}
				pathParameters[key[1:len(key)-1]] = value
			}
		}
	}
	return pathParameters
}