You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: root.go
    path of file: ./repos/devdash/cmd
    
    the code of the file until where you have to start completion: package cmd

// TODO see gocket to make the command right (with possibility to use env variables)

import (
	"fmt"
	"log"
	"os"
	"time"

	"github.com/Phantas0s/devdash/internal"
	"github.com/Phantas0s/devdash/internal/platform"
	"github.com/spf13/cobra"
)

var (
	// Used for flags
	cfgName string
	logpath string
	debug   bool

	rootCmd = &cobra.Command{
		Use:   "devdash",
		Short: "DevDash is a highly configurable terminal dashboard for developers and creators",
		Long:  `DevDash is a highly flexible terminal dashboard for developers and creators, which allows you to gather and refresh the data you really need from Google Analytics, Google Search Console, Github, TravisCI, and more.`,
		Run: func(cmd *cobra.Command, args []string) {
			run()
		},
	}
)

func init() {
	rootCmd.Flags().StringVarP(&cfgName, "config", "c", "", "A valid dashboard configuration")
	// TODO logger
	// rootCmd.Flags().StringVarP(&logpath, "logpath", "l", "", "Path for logging")
	rootCmd.Flags().
    
func run() {
	termui, err := platform.NewTermUI(debug)
	if err != nil {
		fmt.Println(err)
	}

	// Create the TUI.
	tui := internal.NewTUI(termui)
	defer tui.Close()

	// Map dashboard config to a struct Config.
	cfg, cfgFile := mapConfig(cfgName)
	if debug {
		fmt.Fprintf(os.Stdout, "Config file used: %s", cfgFile)
	}

	// Passing a time.Time to this channel reload the entire dashboard.
	hotReload := make(chan time.Time)

	// Add keystrokes to reload and quit
	tui.AddKHotReload(cfg.KHotReload(), hotReload)
	tui.AddKQuit(cfg.KQuit())

	// Passing a bool to this channel stop the automatic reload of the dashboard.
	stopAutoReload := make(chan bool)
	autoReload(cfg.RefreshTime(), stopAutoReload, hotReload)

	editor := os.Getenv("EDITOR")
	if cfg.General.Editor != "" {
		editor = cfg.General.Editor
	}

	// Add keystroke (managed by TUI) to edit the configuration in a CLI editor.
	// Wrap edit config in lambda to defer the execution.
	tui.AddKEdit(
		cfg.KEdit(),
		func() {
			stopReload(stopAutoReload)
			editDashboard(editor, cfgFile)
			hotReload <- time.Now()
			autoReload(cfg.RefreshTime(), stopAutoReload, hotReload)
		},
	)

	// First display.
	build(cfgName, tui)

	// Automatic reload
	go func() {
		for hr := range hotReload {
			tui.HotReload()
			build(cfgName, tui)
			if debug {
				fmt.Println("Last reload: " + hr.Format("2006-01-02 15:04:05"))
			}
		}
	}()

	tui.Loop()
}