<commit_before>package main

import (
	"github.com/evnix/boltdbweb/web"
	"github.com/gin-gonic/gin"
)

import (
	"flag"
	"fmt"
	"os"

	log "github.com/Sirupsen/logrus"
	"github.com/boltdb/bolt"
)

var (
	db         *bolt.DB
	dbName     string
	port       string 
	staticPath string
)

func init() {
	// Read the static path from the environment if set.
	staticPath = os.Getenv("BOLTDBWEB_STATIC_PATH")
	if staticPath == "" {
		staticPath = "."
	}
	dbName = os.Getenv("BOLTDBWEB_DB_NAME")
	port = os.Getenv("BOLTDBWEB_PORT")
	if port == "" {
		port = "8080"
	}
	flag.StringVar(&dbName, "db-name", dbName, "Name of the database")
	flag.StringVar(&port, "port", port, "Port for the web-ui")
	flag.StringVar(&staticPath, "static-path", staticPath, "Path for the static content")
}

func main() {
	flag.Parse()
	args := flag.Args()

	fmt.Print(" ")
	log.Info("starting boltdb-browser..")
	if dbName == nil && len(args) > 0 {
		dbName = args[0]
	}

	if dbName == nil {

		fmt.Println("Usage: " + os.Args[0] + " --db-name=<DBfilename>[required] --port=<port>[optional] --static-path=<static-path>[optional]")
		os.Exit(0)
	}

	var err error
	db, err = bolt.Open(*dbName, 0600, nil)
	boltbrowserweb.Db = db

	if err != nil {

		fmt.Println(err)
		os.Exit(0)
	}

	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})

	r.GET("/", boltbrowserweb.Index)

	r.GET("/buckets", boltbrowserweb.Buckets)
	r.POST("/createBucket", boltbrowserweb.CreateBucket)
	r.POST("/put", boltbrowserweb.Put)
	r.POST("/get", boltbrowserweb.Get)
	r.POST("/deleteKey", boltbrowserweb.DeleteKey)
	r.POST("/deleteBucket", boltbrowserweb.DeleteBucket)
	r.POST("/prefixScan", boltbrowserweb.PrefixScan)

	r.Static("/web", *staticPath+"/web")

	r.Run(":" + *port)

}<commit_msg>Updated CLI to include environment config and improved help message<commit_after>//
// boltdbweb is a webserver base GUI for interacting with BoltDB databases.
//
// For authorship see https://github.com/evnix/boltdbweb
// MIT license is included in repository
//
package main

import (
	"github.com/evnix/boltdbweb/web"
	"github.com/gin-gonic/gin"
)

import (
	"flag"
	"fmt"
	"os"
	"path"

	log "github.com/Sirupsen/logrus"
	"github.com/boltdb/bolt"
)

const version = "v0.0.0"

var (
	showHelp   bool
	db         *bolt.DB
	dbName     string
	port       string
	staticPath string
)

func usage(appName, version string) {
	fmt.Printf("Usage: %s [OPTIONS] [DB_NAME]", appName)
	fmt.Printf("\nOPTIONS:\n\n")
	flag.VisitAll(func(f *flag.Flag) {
		if len(f.Name) > 1 {
			fmt.Printf("    -%s, -%s\t%s\n", f.Name[0:1], f.Name, f.Usage)
		}
	})
	fmt.Printf("\n\nVersion %s\n", version)
}

func init() {
	// Read the static path from the environment if set.
	dbName = os.Getenv("BOLTDBWEB_DB_NAME")
	port = os.Getenv("BOLTDBWEB_PORT")
	staticPath = os.Getenv("BOLTDBWEB_STATIC_PATH")
	// Use default values if environment not set.
	if staticPath == "" {
		staticPath = "."
	}
	if port == "" {
		port = "8080"
	}
	// Setup for command line processing
	flag.BoolVar(&showHelp, "h", false, "display help")
	flag.BoolVar(&showHelp, "help", false, "display help")
	flag.StringVar(&dbName, "d", dbName, "Name of the database")
	flag.StringVar(&dbName, "db-name", dbName, "Name of the database")
	flag.StringVar(&port, "p", port, "Port for the web-ui")
	flag.StringVar(&port, "port", port, "Port for the web-ui")
	flag.StringVar(&staticPath, "s", staticPath, "Path for the static content")
	flag.StringVar(&staticPath, "static-path", staticPath, "Path for the static content")
}

func main() {
	appName := path.Base(os.Args[0])
	flag.Parse()
	args := flag.Args()

	if showHelp == true {
		usage(appName, version)
		os.Exit(0)
	}

	fmt.Print(" ")
	log.Info("starting boltdb-browser..")

	// If non-flag options are included assume bolt db is specified.
	if dbName == nil && len(args) > 0 {
		dbName = args[0]
	}

	if dbName == nil {
		usage(appName, version)
		os.Exit(1)
	}

	var err error
	db, err = bolt.Open(*dbName, 0600, nil)
	boltbrowserweb.Db = db

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// OK, we should be ready to define/run web server safely.
	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})

	r.GET("/", boltbrowserweb.Index)

	r.GET("/buckets", boltbrowserweb.Buckets)
	r.POST("/createBucket", boltbrowserweb.CreateBucket)
	r.POST("/put", boltbrowserweb.Put)
	r.POST("/get", boltbrowserweb.Get)
	r.POST("/deleteKey", boltbrowserweb.DeleteKey)
	r.POST("/deleteBucket", boltbrowserweb.DeleteBucket)
	r.POST("/prefixScan", boltbrowserweb.PrefixScan)

	r.Static("/web", *staticPath+"/web")

	r.Run(":" + *port)
}
{'fraction_non_alphanumeric': 0.17585470085470087, 'fraction_numerical': 0.008333333333333333, 'mean_word_length': 3.7571138211382116, 'pattern_counts': {'":': 4, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 1, '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': '6219305', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1805, 'n_words': 400}