<commit_before>package ksana

import (
	"bytes"
	"container/list"
	"database/sql"
	"errors"
	"flag"
	"fmt"
	"log"
	"net/http"
	"os"
	"strings"
)

const VERSION = "v20150510"

type Application interface {
	Start() error
	Router() Router
	Model() Model
	Mount(path string, engine Engine)
}

func New() (Application, error) {
	actions := []string{"server", "migrate", "rollback", "routes"}
	cfg := flag.String("c", "config.json", "configuration file name")
	act := flag.String("r", "server", "running: "+strings.Join(actions, " | "))
	flag.Parse()

	var err error
	var app Application

	err = ctx.Load(*cfg)
	if err != nil {
		return nil, err
	}

	for _, a := range actions {

		if a == *act {
			app = &application{
				config: *cfg,
				action: *act,
				router: &router{routes: list.New(), templates: "app/views"},
				model:  &model{path: "db/migrate", db: ctx.Get("db").(*sql.DB)},
			}
			break
		}
	}

	if app == nil {
		err = errors.New(
			fmt.Sprintf("Unknown action, please use `%s -h` for more options.",
				os.Args[0]))
	}

	return app, err
}

type application struct {
	config string
	action string

	router Router
	model  Model
}

func (app *application) Mount(p string, e Engine) {
	e.Router(p, app.Router())
}

func (app *application) Model() Model {
	return app.model
}

func (app *application) Router() Router {
	return app.router
}

func (app *application) Start() error {
	var err error

	switch app.action {
	case "server":
		err = app.server()
	case "migrate":
		err = app.model.Migrate()
	case "rollback":
		err = app.model.Rollback()
	case "routes":
		app.routes()
	default:
	}

	return err
}
<commit_msg>call shell command<commit_after>package ksana

import (	
	"bytes"
	"container/list"
	"database/sql"
	"errors"
	"flag"
	"fmt"
	"log"
	"net/http"
	"os"
	"os/exec"
	"strings"
	"syscall"
)

const VERSION = "v20150510"

type Application interface {
	Start() error
	Router() Router
	Model() Model
	Mount(path string, engine Engine)
}

func New() (Application, error) {
	actions := []string{"server", "migrate", "rollback", "routes", "db"}
	cfg := flag.String("c", "config.json", "configuration file name")
	act := flag.String("r", "server", "running: "+strings.Join(actions, " | "))
	flag.Parse()

	var err error
	var app Application

	err = ctx.Load(*cfg)
	if err != nil {
		return nil, err
	}

	for _, a := range actions {

		if a == *act {
			app = &application{
				config: *cfg,
				action: *act,
				router: &router{routes: list.New(), templates: "app/views"},
				model:  &model{path: "db/migrate", db: ctx.Get("db").(*sql.DB)},
			}
			break
		}
	}

	if app == nil {
		err = errors.New(
			fmt.Sprintf("Unknown action, please use `%s -h` for more options.",
				os.Args[0]))
	}

	return app, err
}

type application struct {
	config string
	action string

	router Router
	model  Model
}

func (app *application) Mount(p string, e Engine) {
	e.Router(p, app.Router())
}

func (app *application) Model() Model {
	return app.model
}

func (app *application) Router() Router {
	return app.router
}

func (app *application) Start() error {
	var err error

	switch app.action {
	case "server":
		err = app.server()
	case "migrate":
		err = app.model.Migrate()
	case "rollback":
		err = app.model.Rollback()
	case "routes":
		app.routes()
	case "db":
		err = app.shell("psql", "-U", "postgres")
	default:
	}

	return err
}

func (app *application) shell(cmd string, args ...string) error {
	bin, err := exec.LookPath(cmd)
	if err != nil {
		return err
	}
	return syscall.Exec(bin, append([]string{cmd}, args...), os.Environ())
}

{'fraction_non_alphanumeric': 0.16807432432432431, 'fraction_numerical': 0.005067567567567568, 'mean_word_length': 3.572715572715573, 'pattern_counts': {'":': 9, '<': 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': '3895550', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1317, 'n_words': 368}