<commit_before>package main

import (
	"fmt"
	log "github.com/Sirupsen/logrus"
	"github.com/codegangsta/cli"
	"github.com/jbdalido/smg/engine"
	"github.com/jbdalido/smg/utils"
	"os"
	"os/signal"
)

var (
	smgapp      *engine.Application
	eng         *engine.Engine
	killChannel chan os.Signal
	endChannel  chan error
)

func main() {

	cliApp := cli.App{
		Name:    "smg",
		Usage:   "Run and Build docker - https://smuggler.io",
		Version: "0.4.1",
	}

	cliApp.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "docker, d",
			Value: "",
			Usage: "Docker endpoint",
		},
		cli.StringFlag{
			Name:   "config, c",
			Value:  "~/.smg.yml",
			Usage:  "Config file to use",
			EnvVar: "SMG_CONFIG",
		},
	}

	buildFlags := []cli.Flag{
		cli.StringFlag{
			Name:  "start, s",
			Value: "smg.yml",
			Usage: "Specify a different file to use for your smg run (default: smg.yml)",
		},
		cli.BoolFlag{
			Name:  "no-cache, n",
			Usage: "Disable the use of docker cache during run and build with provided dockerfiles",
		},
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Verbose Mode",
		},
		cli.BoolFlag{
			Name:  "push, p",
			Usage: "Push images after a successful build",
		},
		cli.BoolFlag{
			Name:  "last, l",
			Usage: "Download last image for each build",
		},
		cli.BoolFlag{
			Name:  "delete, D",
			Usage: "Delete images created after a successful build",
		},
		cli.StringSliceFlag{
			Name:  "etcd",
			Value: &cli.StringSlice{},
			Usage: "ETCD Storage http endpoint",
		},
	}

	runFlags := []cli.Flag{
		cli.StringFlag{
			Name:  "start, s",
			Value: "smg.yml",
			Usage: "Specify a different file to use for your smg run (default: smg.yml)",
		},
		cli.BoolFlag{
			Name:  "no-cache, n",
			Usage: "Disable the use of docker cache during run and build with provided dockerfiles",
		},
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Verbose Mode",
		},
		cli.StringFlag{
			Name:  "env, e",
			Value: "default",
			Usage: "Environment (commands or dockerfiles) to use for the run",
		},
		cli.StringSliceFlag{
			Name:  "override, o",
			Value: &cli.StringSlice{},
			Usage: "Environment (commands or dockerfiles) to use for the run",
		},
		cli.BoolFlag{
			Name:  "keepalive, k",
			Usage: "Keep containers alive after a run (successful or not)",
		},
		cli.BoolFlag{
			Name:  "shared-folder, S",
			Usage: "Use a shared-folder with the main container",
		},
	}

	cliApp.HideVersion = true

	cliApp.Commands = []cli.Command{
		cli.Command{
			Name:   "run",
			Usage:  "Run containers with the proper environment",
			Flags:  runFlags,
			Action: CmdRun,
		},
		cli.Command{
			Name:   "build",
			Usage:  "Build against the active git branch of the folder and the build setup of the smg file",
			Flags:  buildFlags,
			Action: CmdBuild,
		},
	}

	cliApp.Run(os.Args)

}

func Init(c *cli.Context) error {

	utils.InitLogger(c.Bool("verbose"))
	killChannel = make(chan os.Signal, 1)
	endChannel = make(chan error)

	// Start by checking if config exist
	cfg, err := engine.NewConfig(c.GlobalString("config"), c.GlobalString("docker"))<commit_msg>fixe when no args are passed to smg<commit_after>package main

import (
	"fmt"
	log "github.com/Sirupsen/logrus"
	"github.com/codegangsta/cli"
	"github.com/jbdalido/smg/engine"
	"github.com/jbdalido/smg/utils"
	"os"
	"os/signal"
)

var (
	smgapp      *engine.Application
	eng         *engine.Engine
	killChannel chan os.Signal
	endChannel  chan error
)

func main() {

	cliApp := cli.App{
		Name:    "smg",
		Usage:   "Run and Build docker - https://smuggler.io",
		Version: "0.4.1",
	}

	cliApp.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "docker, d",
			Value: "",
			Usage: "Docker endpoint",
		},
		cli.StringFlag{
			Name:   "config, c",
			Value:  "~/.smg.yml",
			Usage:  "Config file to use",
			EnvVar: "SMG_CONFIG",
		},
	}

	buildFlags := []cli.Flag{
		cli.StringFlag{
			Name:  "start, s",
			Value: "smg.yml",
			Usage: "Specify a different file to use for your smg run (default: smg.yml)",
		},
		cli.BoolFlag{
			Name:  "no-cache, n",
			Usage: "Disable the use of docker cache during run and build with provided dockerfiles",
		},
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Verbose Mode",
		},
		cli.BoolFlag{
			Name:  "push, p",
			Usage: "Push images after a successful build",
		},
		cli.BoolFlag{
			Name:  "last, l",
			Usage: "Download last image for each build",
		},
		cli.BoolFlag{
			Name:  "delete, D",
			Usage: "Delete images created after a successful build",
		},
		cli.StringSliceFlag{
			Name:  "etcd",
			Value: &cli.StringSlice{},
			Usage: "ETCD Storage http endpoint",
		},
	}

	runFlags := []cli.Flag{
		cli.StringFlag{
			Name:  "start, s",
			Value: "smg.yml",
			Usage: "Specify a different file to use for your smg run (default: smg.yml)",
		},
		cli.BoolFlag{
			Name:  "no-cache, n",
			Usage: "Disable the use of docker cache during run and build with provided dockerfiles",
		},
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Verbose Mode",
		},
		cli.StringFlag{
			Name:  "env, e",
			Value: "default",
			Usage: "Environment (commands or dockerfiles) to use for the run",
		},
		cli.StringSliceFlag{
			Name:  "override, o",
			Value: &cli.StringSlice{},
			Usage: "Environment (commands or dockerfiles) to use for the run",
		},
		cli.BoolFlag{
			Name:  "keepalive, k",
			Usage: "Keep containers alive after a run (successful or not)",
		},
		cli.BoolFlag{
			Name:  "shared-folder, S",
			Usage: "Use a shared-folder with the main container",
		},
	}

	cliApp.HideVersion = true

	cliApp.Commands = []cli.Command{
		cli.Command{
			Name:   "run",
			Usage:  "Run containers with the proper environment",
			Flags:  runFlags,
			Action: CmdRun,
		},
		cli.Command{
			Name:   "build",
			Usage:  "Build against the active git branch of the folder and the build setup of the smg file",
			Flags:  buildFlags,
			Action: CmdBuild,
		},
	}

	// TODO : something is not right here !
	if len(os.Args) == 1 {
		os.Args = append(os.Args, "help")
	}
	cliApp.Run(os.Args)

}

func Init(c *cli.Context) error {

	utils.InitLogger(c.Bool("verbose"))
	killChannel = make(chan os.Signal, 1)
	endChannel = make(chan error)

	// Start by checking if config exist
	cfg, err := engine.NewConfig(c.GlobalString("config"), c.GlobalString("docker"))
{'fraction_non_alphanumeric': 0.14401913875598085, 'fraction_numerical': 0.0014354066985645933, 'mean_word_length': 3.1121311475409836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3037757', 'n_tokens_mistral': 2593, 'n_tokens_neox': 2272, 'n_words': 656}