<commit_before>package loader

import (
	"errors"
	"os"
	"path/filepath"
	"reflect"
	"strings"

	"github.com/fatih/camelcase"
	"github.com/fatih/images/command/flags"
	"github.com/fatih/structs"
	"github.com/koding/multiconfig"
)

var (
	DefaultConfigName = "imagesrc"
)

// Load loads the given config to the rules of images CLI
func Load(conf interface{}, args []string) error {
	configArgs := []string{}

	// need to be declared so we can call it recursively :)
	var addFields func(fields []*structs.Field)

	// only pass the config's field names arguments. This means we create an
	// argument list that contains flag names and their values which are only
	// declared in the passed "conf" struct. Any other argument is discarded
	addFields = func(fields []*structs.Field) {
		for _, field := range fields {
			// don't forget nested structs
			if field.Kind() == reflect.Struct {
				addFields(field.Fields())
			}

			fName := strings.ToLower(strings.Join(camelcase.Split(field.Name()), "-"))

			val, err := flags.ParseValue(fName, args)
			if err != nil {
				continue
			}

			configArgs = append(configArgs, "--"+fName, val)
		}
	}
	addFields(structs.Fields(conf))

	loaders := []multiconfig.Loader{}

	// check for any files<commit_msg>loader: don't take inner struct field names<commit_after>package loader

import (
	"errors"
	"os"
	"path/filepath"
	"reflect"
	"strings"

	"github.com/fatih/camelcase"
	"github.com/fatih/images/command/flags"
	"github.com/fatih/structs"
	"github.com/koding/multiconfig"
)

var (
	DefaultConfigName = "imagesrc"
)

// Load loads the given config to the rules of images CLI
func Load(conf interface{}, args []string) error {
	configArgs := []string{}

	// need to be declared so we can call it recursively :)
	var addFields func(fields []*structs.Field)

	// only pass the config's field names arguments. This means we create an
	// argument list that contains flag names and their values which are only
	// declared in the passed "conf" struct. Any other argument is discarded
	addFields = func(fields []*structs.Field) {
		for _, field := range fields {
			// don't forget nested structs
			if field.Kind() == reflect.Struct {
				addFields(field.Fields())
				continue
			}

			fName := strings.ToLower(strings.Join(camelcase.Split(field.Name()), "-"))
			val, err := flags.ParseValue(fName, args)
			if err != nil {
				continue
			}

			configArgs = append(configArgs, "--"+fName, val)
		}
	}
	addFields(structs.Fields(conf))

	loaders := []multiconfig.Loader{}

	// check for any files
{'fraction_non_alphanumeric': 0.12933753943217666, 'fraction_numerical': 0.0, 'mean_word_length': 3.689463955637708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5596056', 'n_tokens_mistral': 889, 'n_tokens_neox': 809, 'n_words': 244}