<commit_before>package main

import (
	"fmt"
	"os"
	"path"

	"gopkg.in/alecthomas/kingpin.v2"

	. "github.com/dpecos/dotback/utils"
)

func readConfig() Config {
	file := path.Join(HomeDir(), ".dotfiles", "config")

	var config Config
	config.Load(file)

	return config
}

func executeRecipes(config Config) {
	for _, recipe := range config.Recipes {
		recipe.Execute()
	}
}

var (
	app = kingpin.New("dotback", "Handle your dot files like a boss")
	// initialize = app.Command("init", "Use a Git repository to initialize your dotfiles folder")
	pull    = app.Command("pull", "Fetch latest changes from remote dotfiles repository")
	push    = app.Command("push", "Send latest changes to remote dotfiles repository")
	list    = app.Command("list", "List the actions defined in your ~/.dotfiles/config.json")
	install = app.Command("install", "Performs the actions defined in your ~/.dotfiles/config.json")
	recipe  = install.Arg("recipe", "Execute only this recipe").String()
	// add        = app.Command("add", "Creates a new recipe")
	// delete     = app.Command("delete", "Remove a recipe")
)

func main() {

	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
	case "pull":
		path := path.Join(HomeDir(), ".dotfiles")
		err := Execute(fmt.Sprintf("cd %s && git pull", path))
		CheckError("Error updating repository", err)
	case "push":
		path := path.Join(HomeDir(), ".dotfiles")
		err := Execute(fmt.Sprintf("cd %s && git push", path))
		CheckError("Error updating repository", err)
	case "list":
		config := readConfig()
		for _, recipe := range config.Recipes {
			fmt.Printf("%s %s -> \n", recipe.Name, recipe.Attributes)

			for _, action := range recipe.Actions {
				fmt.Printf("   %s: %s\n", action.GetName(), action.GetArguments())
			}
			fmt.Println("")
		}
	case "install":
		config := readConfig()
		executeRecipes(config)
	}
}<commit_msg>Filter what recipes to install<commit_after>package main

import (
	"fmt"
	"os"
	"path"

	"gopkg.in/alecthomas/kingpin.v2"

	. "github.com/dpecos/dotback/utils"
)

func readConfig() Config {
	file := path.Join(HomeDir(), ".dotfiles", "config")

	var config Config
	config.Load(file)

	return config
}

func executeRecipes(config Config, recipeName *string) {
	for _, recipe := range config.Recipes {
		if recipeName != nil {
			if *recipeName == recipe.Name {
				recipe.Execute()
			}
		} else {
			recipe.Execute()
		}
	}
}

var (
	app = kingpin.New("dotback", "Handle your dot files like a boss")
	// initialize = app.Command("init", "Use a Git repository to initialize your dotfiles folder")
	pull    = app.Command("pull", "Fetch latest changes from remote dotfiles repository")
	push    = app.Command("push", "Send latest changes to remote dotfiles repository")
	list    = app.Command("list", "List the actions defined in your ~/.dotfiles/config.json")
	install = app.Command("install", "Performs the actions defined in your ~/.dotfiles/config.json")
	recipe  = install.Arg("recipe", "Execute only this recipe").String()
	// add        = app.Command("add", "Creates a new recipe")
	// delete     = app.Command("delete", "Remove a recipe")
)

func main() {

	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
	case "pull":
		path := path.Join(HomeDir(), ".dotfiles")
		err := Execute(fmt.Sprintf("cd %s && git pull", path))
		CheckError("Error updating repository", err)
	case "push":
		path := path.Join(HomeDir(), ".dotfiles")
		err := Execute(fmt.Sprintf("cd %s && git push", path))
		CheckError("Error updating repository", err)
	case "list":
		config := readConfig()
		for _, recipe := range config.Recipes {
			fmt.Printf("%s %s -> \n", recipe.Name, recipe.Attributes)

			for _, action := range recipe.Actions {
				fmt.Printf("   %s: %s\n", action.GetName(), action.GetArguments())
			}
			fmt.Println("")
		}
	case "install":
		config := readConfig()
		executeRecipes(config, recipe)
	}
}
{'fraction_non_alphanumeric': 0.1623023074928701, 'fraction_numerical': 0.0010370754472387865, 'mean_word_length': 3.9272030651340994, 'pattern_counts': {'":': 8, '<': 3, '<?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': '5744921', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1260, 'n_words': 345}