<commit_before>package main

import (
	"flag"
	"fmt"
	"os"

	"github.com/michaelgaida/consul-mirror/configuration"
	"github.com/michaelgaida/consul-mirror/consul"
	"github.com/michaelgaida/consul-mirror/storage"
)

func main() {
	var (
		validate = flag.String("validate", "", "configuration file to be validated")
	)

	flag.Parse()

	if *validate != "" {
		// check the new config
		testConfiguration := configuration.GetConfig(*validate)
		os.Exit(testConfiguration.ValidateConfiguration())
	}

	config := configuration.GetConfig("config.json")
	if config.Debug {
		fmt.Printf(config.PrintDebug())
	}

	// s := storage.Mssql{}
	conn := storage.OpenConnection(config)
	defer conn.Close()

	consul := consul.GetConsul(config)
	kvs := consul.GetKVs("")
	if kvs == nil {
	}
	conn.WriteKVs(kvs)
	services := consul.GetServices()
	if services == nil {

	}
	nodes := consul.GetNodes()
	if nodes == nil {

	}
}<commit_msg>changed cli parsing<commit_after>package main

import (
	"fmt"
	"log"
	"os"

	"github.com/michaelgaida/consul-mirror/configuration"
	"github.com/michaelgaida/consul-mirror/consul"
	"github.com/michaelgaida/consul-mirror/storage"
	"github.com/urfave/cli"
)

func main() {
	app := cli.NewApp()
	app.Name = "consul-mirror"
	app.Version = "0.1.0"

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "validate",
			Value: "",
			Usage: "configuration file to be validated",
		},
		cli.BoolFlag{
			Name:  "verbose",
			Usage: "Switch on the verbose mode",
		},
	}

	app.Commands = []cli.Command{
		cli.Command{
			Name:  "import",
			Usage: "import from consul",
		},
		cli.Command{
			Name:  "export",
			Usage: "export from consul",
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "dc",
					Usage: "keep the dcs",
				},
			},
		},
	}

	app.Action = func(c *cli.Context) error {
		if c.String("validate") != "" {
			testConfiguration := configuration.GetConfig(c.String("validate"))
			os.Exit(testConfiguration.ValidateConfiguration())
		}
		if (!(c.Bool("import"))) && (!(c.Bool("export"))) {
			fmt.Println("Nothing to do")
			os.Exit(0)
		}
		config := configuration.GetConfig("config.json")
		if c.Bool("verbose") {
			config.Debug = true
		}
		if config.Debug {
			log.Printf(config.PrintDebug())
		}

		// s := storage.Mssql{}
		conn := storage.OpenConnection(config)
		// defer conn.Close()

		consul := consul.GetConsul(config)

		dcs := consul.GetDCs()

		if c.Bool("export") {
			kvs := consul.GetKVs("", dcs)
			if kvs == nil {
			}
			conn.WriteKVs(kvs)
		}

		if c.Bool("import") {
			kvs, _ := conn.GetKVs()
			err := consul.WriteKVs(kvs, c.Bool("dc"))
			if err != nil {
				log.Fatal(err)
			}
		}

		return nil
	}

	app.Run(os.Args)
}
{'fraction_non_alphanumeric': 0.17290419161676646, 'fraction_numerical': 0.0014970059880239522, 'mean_word_length': 3.3747954173486088, 'pattern_counts': {'":': 0, '<': 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': '2412341', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1009, 'n_words': 182}