func main() {
	flag.Parse()

	if *exclude != "" {
		for _, pattern := range strings.Split(*exclude, ",") {
			excludes = append(excludes, regexp.MustCompile(pattern))
		}
	}

	if data, err := vfs.ReadFile(context.Background(), *vnamesConfigPath); err != nil {
		log.Fatalf("Unable to read VNames config file %q: %v", *vnamesConfigPath, err)
	} else if rules, err := vnameutil.ParseRules(data); err != nil {
		log.Fatalf("Invalid VName rules: %v", err)
	} else {
		fileRules = rules
	}

	dirs := flag.Args()
	if len(dirs) == 0 {
		dirs = []string{"."}
	}

	for _, dir := range dirs {
		if err := filepath.Walk(dir, emitPath); err != nil {
			log.Fatalf("Error walking %s: %v", dir, err)
		}
	}
}
Beispiel #2
0
// loadVNameRules reads the contents of the file at path and decodes it as a
// slice of vname rewriting rules. The result is empty if path == "".
func loadVNameRules(path string) (vnameutil.Rules, error) {
	if path == "" {
		return nil, nil
	}
	bits, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	return vnameutil.ParseRules(bits)
}