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: run.go
    path of file: ./repos/envkey/public/sdks/envkey-source/cmd
    
    the code of the file until where you have to start completion: package cmd

import (
	"fmt"
	"log"
	"os"
	"os/signal"
	"path/filepath"
	"strings"
	"syscall"

	"github.com/envkey/envkey/public/sdks/envkey-source/daemon"
	"github.com/envkey/envkey/public/sdks/envkey-source/env"
	"github.com/envkey/e
    
func run(cmd *cobra.Command, args []string, firstAttempt bool) {
	if printVersion {
		fmt.Println(version.Version)
		return
	}

	if killDaemon {
		daemon.Stop()
		return
	}

	if daemonMode {
		daemon.InlineStart(shouldCache, memCache)
		return
	}

	if shellHook != "" {
		shell.Hook(shellHook)
		return
	}

	if unset {
		fmt.Println(shell.Unload())
		return
	}

	initClientLogging()

	if len(args) > 0 && strings.TrimSpace(args[0]) != "" {
		execCmdArg = strings.Join(args, " ")
	}

	if (clientNameArg != "" && clientVersionArg == "") ||
		(clientVersionArg != "" && clientNameArg == "") {
		utils.Fatal("if one of --client-name or --client-version is set, the other must also be set", execCmdArg != "")
	}

	var envkey string
	var appConfig env.AppConfig
	var overrides parser.EnvMap
	var err error
	/*
			* ENVKEY lookup order:
			*		1 - ENVKEY environment variable is set
			*   2 - --env-file override is set
			*		3 - A - .env file in current or parent directory
			*
		  *				-- OR --
			*
			*				B - .envkey config file in current or parent directory {appId: string, orgId: string}
			*						+ file at ~/.envkey/apps/[appId].env (for local keys mainly)
			*
			*				Whichever is closer to current directory wins -- .env file takes precendence if both are
			*		    same depth.
			*	  4 - .env file at ~/.env
	*/

	envkey, appConfig, overrides = env.GetEnvkey(verboseOutput, envFileOverride, execCmdArg != "", localDevHost)

	if resolveEnvkey {
		fmt.Print(envkey)
		return
	}

	if envkey == "" {
		if ignoreMissing {
			os.Exit(0)
		} else {
			utils.Fatal("ENVKEY missing\n", execCmdArg != "")
		}
	}

	if verboseOutput {
		fmt.Fprintln(os.Stderr, "loaded ENVKEY")
	}

	var clientName string
	var clientVersion string

	if clientNameArg != "" && clientVersion != "" {
		clientName = clientNameArg
		clientVersion = clientVersionArg
	} else {
		clientName = "envkey-source"
		clientVersion = version.Version
	}

	var res parser.EnvMap

	fetchOpts := fetch.FetchOptions{shouldCache, cacheDir, clientName, clientVersion, verboseOutput, timeoutSeconds, retries, retryBackoff}

	if memCache || onChangeCmdArg != "" || (execCmdArg != "" && watch) {
		daemon.LaunchDetachedIfNeeded(daemon.DaemonOptions{
			verboseOutput,
			shouldCache,
			memCache,
		})
		res, _, err = daemon.FetchMap(envkey, clientName, clientVersion, rollingReload, rollingPct, watchThrottle)

		if err != nil {
			res, err = fetch.FetchMap(envkey, fetchOpts)
		}
	} else {
		res, err = fetch.FetchMap(envkey, fetchOpts)
	}

	if err != nil && err.Error() == "ENVKEY invalid" && appConfig.AppId != "" && firstAttempt {
		// clear out incorrect ENVKEY and try again
		env.ClearAppEnvkey(appConfig.AppId)
		run(cmd, args, false)
		return
	}

	utils.CheckError(err, execCmdArg != "")

	closed = make(chan os.Signal)
	signal.Notify(closed, os.Interrupt, syscall.SIGTERM)

	go func() {
		sig := <-closed
		// stderrLogger.Println(utils.FormatTerminal(" | received "+sig.String()+" signal--cleaning up and exiting", nil))
		log.Println("Received " + sig.String() + " signal. Cleaning up and exiting.")
		if sig == os.Interrupt {
			killWatchCommandIfRunning(syscall.SIGINT)
		} else if sig == syscall.SIGTERM {
			killWatchCommandIfRunning(syscall.SIGTERM)
		}

		os.Exit(0)
	}()

	if !force {
		for k, v := range overrides {
			if k != "ENVKEY" && os.Getenv(k) == "" {
				res[k] = v
			}
		}

		for k, _ := range res {
			if os.Getenv(k) != "" {
				res[k] = os.Getenv(k)
			}
		}
	}

	execWithEnv(envkey, res, clientName, clientVersion)
}