<commit_before>package main

import (
	"encoding/json"
	"log"
	"os"

	"github.com/builderscon/octav/octav"
	"github.com/builderscon/octav/octav/db"
	"github.com/jessevdk/go-flags"
)

type options struct {
	Config string `short:"c" long:"config" description:"path to a config file"`
	Listen string `short:"l" long:"listen" default:":8080" description:"Listen address"`
}

type config struct {
	Listen   string    `json:"listen"`
	Database db.Config `json:"database"`
}

func main() { os.Exit(_main()) }
func _main() int {
	var opts options
	if _, err := flags.Parse(&opts); err != nil {
		log.Printf("%s", err)
		return 1
	}

	if fn := opts.Config; fn != "" {
		var c config
		fh, err := os.Open(fn)
		if err != nil {
			log.Printf("%s", err)
			return 1
		}
		if err := json.NewDecoder(fh).Decode(&c); err != nil {
			log.Printf("%s", err)
			return 1
		}

		if err := db.Init(c.Database.DSN); err != nil {<commit_msg>Dirty hack to forcefully call db.Init<commit_after>package main

import (
	"encoding/json"
	"log"
	"os"

	"github.com/builderscon/octav/octav"
	"github.com/builderscon/octav/octav/db"
	"github.com/jessevdk/go-flags"
)

type options struct {
	Config string `short:"c" long:"config" description:"path to a config file"`
	Listen string `short:"l" long:"listen" default:":8080" description:"Listen address"`
}

type config struct {
	Listen   string    `json:"listen"`
	Database db.Config `json:"database"`
}

func main() { os.Exit(_main()) }
func _main() int {
	var opts options
	if _, err := flags.Parse(&opts); err != nil {
		log.Printf("%s", err)
		return 1
	}

	fn := opts.Config
	if fn == "" {
		// No configuration? do the best we can
		if err := db.Init(""); err != nil {
			log.Printf("%s", err)
			return 1
		}
	} else {
		var c config
		fh, err := os.Open(fn)
		if err != nil {
			log.Printf("%s", err)
			return 1
		}
		if err := json.NewDecoder(fh).Decode(&c); err != nil {
			log.Printf("%s", err)
			return 1
		}

		if err := db.Init(c.Database.DSN); err != nil {
{'fraction_non_alphanumeric': 0.1737820190858865, 'fraction_numerical': 0.007533902561526871, 'mean_word_length': 3.4966139954853275, 'pattern_counts': {'":': 2, '<': 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': '3186066', 'n_tokens_mistral': 793, 'n_tokens_neox': 736, 'n_words': 194}