<commit_before>package main

import (
	"flag"
	"io/ioutil"
	"log"
	"os"
	"os/exec"
	"strings"

	"github.com/mwek/iblameyou/internal"
	"gopkg.in/yaml.v2"
)

var config = flag.String("config",
	os.Getenv("HOME")+"/.iblameyou.yaml",
	"path to configuration file")

type Config struct {
	Format internal.Format
	Source internal.Source
}

func DefaultConfig() (c Config) {
	c.Format.Colors = internal.DefaultPalette()
	cmd := exec.Command("git", "rev-parse", "--show-toplevel")
	cmd.Stderr = ioutil.Discard
	if repo, err := cmd.Output(); err == nil {
		c.Source.Repository = strings.TrimSpace(string(repo))
	}
	return c
}

func main() {
	flag.Parse()

	cfg := DefaultConfig()
	if b, err := ioutil.ReadFile(*config); err == nil {
		if err := yaml.Unmarshal(b, &cfg); err != nil {
			log.Fatalf("Failed to unmarshal config:\n%s", err)
		}
	}

	if cfg.Source.Repository == "" {
		log.Fatal("Repository not provided and not in a Git repository.")
	}

	ui := internal.UI{}
	err := ui.Init(&cfg.Format)
	if err != nil {<commit_msg>Add version flag.<commit_after>package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"os/exec"
	"strings"

	"github.com/mwek/iblameyou/internal"
	"gopkg.in/yaml.v2"
)

const v = "0.1"

var (
	version = flag.Bool("version", false, "print version and exit")
	config  = flag.String("config",
		os.Getenv("HOME")+"/.iblameyou.yaml",
		"path to configuration file")
)

type Config struct {
	Format internal.Format
	Source internal.Source
}

func DefaultConfig() (c Config) {
	c.Format.Colors = internal.DefaultPalette()
	cmd := exec.Command("git", "rev-parse", "--show-toplevel")
	cmd.Stderr = ioutil.Discard
	if repo, err := cmd.Output(); err == nil {
		c.Source.Repository = strings.TrimSpace(string(repo))
	}
	return c
}

func main() {
	flag.Parse()

	if *version {
		fmt.Println(v)
		os.Exit(0)
	}

	cfg := DefaultConfig()
	if b, err := ioutil.ReadFile(*config); err == nil {
		if err := yaml.Unmarshal(b, &cfg); err != nil {
			log.Fatalf("Failed to unmarshal config:\n%s", err)
		}
	}

	if cfg.Source.Repository == "" {
		log.Fatal("Repository not provided and not in a Git repository.")
	}

	ui := internal.UI{}
	err := ui.Init(&cfg.Format)
	if err != nil {
{'fraction_non_alphanumeric': 0.17534246575342466, 'fraction_numerical': 0.00228310502283105, 'mean_word_length': 3.752711496746204, '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': '838277', 'n_tokens_mistral': 863, 'n_tokens_neox': 831, 'n_words': 193}