<commit_before>// (c) 2021 <NAME>, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package config

import (
	"flag"
	"fmt"
	"io"
	"os"

	"github.com/spf13/viper"
)

// BuildViper returns the viper environment from parsing config file from
// default search paths and any parsed command line flags
func BuildViper(fs *flag.FlagSet, args []string) (*viper.Viper, error) {
	pfs, err := buildPFlagSet(fs)
	if err != nil {
		return nil, err
	}
	if err := pfs.Parse(args); err != nil {
		return nil, err
	}

	v := viper.New()
	if err := v.BindPFlags(pfs); err != nil {<commit_msg>Configuration via env vars in avalanchego (#678)<commit_after>// (c) 2021 <NAME>, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package config

import (
	"flag"
	"fmt"
	"io"
	"os"
	"strings"

	"github.com/spf13/viper"
)

// BuildViper returns the viper environment from parsing config file from
// default search paths and any parsed command line flags
func BuildViper(fs *flag.FlagSet, args []string) (*viper.Viper, error) {
	pfs, err := buildPFlagSet(fs)
	if err != nil {
		return nil, err
	}
	if err := pfs.Parse(args); err != nil {
		return nil, err
	}

	v := viper.New()
	v.AutomaticEnv()
	v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
	v.SetEnvPrefix("avago")
	if err := v.BindPFlags(pfs); err != nil {
{'fraction_non_alphanumeric': 0.14136125654450263, 'fraction_numerical': 0.011219147344801795, 'mean_word_length': 3.7615658362989324, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4352679', 'n_tokens_mistral': 506, 'n_tokens_neox': 479, 'n_words': 156}