<commit_before>package main

import (
	"./goleg"
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"net/http"
)

type Config struct {
	// Base settings (required)
	Listen  string
	DataDir string
	// HTTPS settings
	UseHTTPS bool
	CertFile string
	PkeyFile string
}

var config Config
var databases map[string]goleg.Database

func main() {
	// Parse command line flags (if there are)
	directory := flag.String("dir", "", "Directory where to store dumps and data")
	configfile := flag.String("config", "olegdb.conf", "Config file to read settings from")
	bindaddr := flag.String("bind", "", "Address and port to bind, host:port")

	flag.Parse()

	// Parse config file
	rawconf, err := ioutil.ReadFile(*configfile)
	if err != nil {
		panic(err.Error())
	}
	err = json.Unmarshal(rawconf, &config)
	if err != nil {
		panic(err.Error())
	}

	databases = make(map[string]goleg.Database)

	// Override config option with command line ones
	if *directory != "" {
		config.DataDir = *directory
	}

	if *bindaddr != "" {
		config.Listen = *bindaddr
	}

	http.HandleFunc("/", handler)
	defer unload()
	fmt.Println("Listening on " + config.Listen)
	if config.UseHTTPS {
		http.ListenAndServeTLS(config.Listen, config.CertFile, config.PkeyFile, nil)
	} else {<commit_msg>Cleaner errors, still needs some work<commit_after>package main

import (
	"./goleg"
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"net/http"
	"log"
	"os"
)

type Config struct {
	// Base settings (required)
	Listen  string
	DataDir string
	// HTTPS settings
	UseHTTPS bool
	CertFile string
	PkeyFile string
}

var config Config
var databases map[string]goleg.Database

const (
Usage = `
Usage: %s -config <config path> [options]
	Config path:
		Path to a configuration file. This is required.
Options:
	-bind
		Override Listen directive in configuration.
	-dir
		Override db storage location in configuration.
	-v
		Version
	-h
		This help.
`
)


func main() {
	// Parse command line flags (if there are)
	directory := flag.String("dir", "", "Directory where to store dumps and data")
	configfile := flag.String("config", "olegdb.conf", "Config file to read settings from")
	bindaddr := flag.String("bind", "", "Address and port to bind, host:port")

	flag.Parse()

	if configfile == nil {
		text := fmt.Sprintf(Usage, os.Args[0])
		log.Print("Config file is required")
		log.Fatal(text)
	}

	// Parse config file
	rawconf, err := ioutil.ReadFile(*configfile)
	if err != nil {
		log.Fatal("Could not read configuration. Please see the documentation.")
	}
	err = json.Unmarshal(rawconf, &config)
	if err != nil {
		panic(err.Error())
	}

	databases = make(map[string]goleg.Database)

	// Override config option with command line ones
	if *directory != "" {
		config.DataDir = *directory
	}

	if *bindaddr != "" {
		config.Listen = *bindaddr
	}

	http.HandleFunc("/", handler)
	defer unload()
	fmt.Println("Listening on " + config.Listen)
	if config.UseHTTPS {
		http.ListenAndServeTLS(config.Listen, config.CertFile, config.PkeyFile, nil)
	} else {
{'fraction_non_alphanumeric': 0.13362212595801398, 'fraction_numerical': 0.0003332222592469177, 'mean_word_length': 3.8892508143322475, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4392212', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1022, 'n_words': 296}