<commit_before>package main

import (
	"git.ianfross.com/ifross/expensetracker/auth"
	"git.ianfross.com/ifross/expensetracker/env"
	"git.ianfross.com/ifross/expensetracker/handlers"
	"git.ianfross.com/ifross/expensetracker/models"
	"git.ianfross.com/ifross/expensetracker/models/postgrestore"

	"github.com/jmoiron/sqlx"
	"github.com/julienschmidt/httprouter"

	"fmt"
	"io"
	"net/http"
	"os"
	"flag"
	"time"
)

var (
	dbUser = flag.String("db-user", "expensetracker", "database user to connect with")
	dbName = flag.String("db-name", "expensetracker", "name of the database to connect to")
	dbPw = flag.String("db-pw", "", "user's database password")
	port = flag.Int("port", 8181, "HTTP port to listen on")

)

func main() {
	db := sqlx.MustOpen("postgres", "user=ian dbname=expensetrackerv2 password=<PASSWORD> sslmode=disable")
	store := postgrestore.MustCreate(db)
	sessionStore := auth.NewCookieSessionStore(
		[]byte("new-authentication-key"),
		[]byte("new-encryption-key"))

	um := auth.NewUserManager(nil, store, nil, sessionStore)
	m := models.NewManager(store)
	//store.MustCreateTypes()
	//store.MustCreateTables()
	store.MustPrepareStmts()
<commit_msg>basic command line options done with mechanism<commit_after>package main

import (
	"git.ianfross.com/ifross/expensetracker/auth"
	"git.ianfross.com/ifross/expensetracker/env"
	"git.ianfross.com/ifross/expensetracker/handlers"
	"git.ianfross.com/ifross/expensetracker/models"
	"git.ianfross.com/ifross/expensetracker/models/postgrestore"

	"github.com/jmoiron/sqlx"
	"github.com/julienschmidt/httprouter"

	"fmt"
	"io"
	"net/http"
	"os"
	"flag"
	"strings"
	"time"
)

type actionsMap map[string]func() error

func (a actionsMap) available() string {
	var actions []string
	for k, _ := range a{
		actions = append(actions, k)
	}
	return "[" + strings.Join(actions, ", ") + "]"
}

func (a actionsMap) validAction(action string) bool {
	_, ok := a[action]
	return ok
}

func (a actionsMap) perform(action string) {
	err := a[action]()
	if err != nil {
		panic(err)
	}
}


var (
	dbUser = flag.String("db-user", "expensetracker", "database user to connect with")
	dbName = flag.String("db-name", "expensetracker", "name of the database to connect to")
	dbPw = flag.String("db-pw", "", "user's database password")
	port = flag.Int("port", 8181, "HTTP port to listen on")
	action = flag.String("action", "start", "action to perform. Available: " + actions.available())
)

var actions = actionsMap{
	"start": start,
}

var start = func() error {
	fmt.Println("dbUser:", *dbUser, "dbName:", *dbName, "dbPw:", *dbPw, "port:", *port)
	return nil
}

func main() {
	flag.Parse()
	if !actions.validAction(*action) {
		fmt.Println("Please choose a valid action. Available: " + actions.available())
		os.Exit(1)
	}

	actions.perform(*action)

	panic("end")
	db := sqlx.MustOpen("postgres", "user=ian dbname=expensetrackerv2 password=wedge89 sslmode=disable")
	store := postgrestore.MustCreate(db)
	sessionStore := auth.NewCookieSessionStore(
		[]byte("new-authentication-key"),
		[]byte("new-encryption-key"))

	um := auth.NewUserManager(nil, store, nil, sessionStore)
	m := models.NewManager(store)
	//store.MustCreateTypes()
	//store.MustCreateTables()
	store.MustPrepareStmts()

{'fraction_non_alphanumeric': 0.16377708978328173, 'fraction_numerical': 0.004024767801857585, 'mean_word_length': 5.107750472589792, 'pattern_counts': {'":': 1, '<': 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': '5148199', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1198, 'n_words': 233}