cmd

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ComputerSetupCmd = &cobra.Command{
	Use: "computer-setup",
	Aliases: []string{
		"computersetup",
		"cs",
		"setup",
	},
	Short: "Configure host to developer preferences (cross platform)",
	Run: func(cmd *cobra.Command, args []string) {
		usrHomeDir, err := homedir.Dir()
		if err != nil {
			log.Fatal("Error getting user home directory")
		}

		err = computerSetup.DirectoryForSourceCode(usrHomeDir)
		if err != nil {
			log.Fatal("Error creating src directory")
		}
		log.Println("$HOME/src is available")

		err = computerSetup.DirectoryForUserBin(usrHomeDir)
		if err != nil {
			log.Fatal("Error creating src directory")
		}
		log.Println("$HOME/bin is available")

		tokenProvider := externalapi.GithubAuthTokenProvider{}
		githubClientProvider := externalapi.GithubClientProvider{}
		dotfiles, err := externalapi.GetMyDotfiles(&tokenProvider, &githubClientProvider)
		if err != nil {
			log.Fatalf("Error getting dotfiles %v", err)
		}

		token, err := tokenProvider.GetAuthToken()
		if err != nil {
			log.Fatalf("Error getting github auth token %v", err)
		}
		ghClient, err := githubClientProvider.GetGithubClient(token)
		if err != nil {
			log.Fatalf("Error getting github client %v", err)
		}
		user, _, err := ghClient.Users.Get(context.TODO(), "")
		if err != nil {
			log.Fatalf("Error getting github user %v", err)
		}

		gitProvider := externalcmd.GitClientProvider{}
		auth := &http.BasicAuth{
			Username: *user.Login,
			Password: token,
		}
		for _, repo := range dotfiles {
			_, innerErr := externalcmd.CloneGithubRepo(path.Join(usrHomeDir, "src"), &gitProvider, &repo, auth)
			if innerErr != nil {
				log.Fatalf("Error cloning repo %v", innerErr)
			}
		}
	},
}

ComputerSetupCmd defines the root of computer setup

View Source
var StatusCmd = &cobra.Command{
	Use:   "status",
	Short: "Checks the status of the machine for expected setup",
	Run: func(cmd *cobra.Command, args []string) {
		usrHomeDir, err := homedir.Dir()
		if err != nil {
			log.Fatal("Error getting user home directory")
		}

		output := bytes.NewBufferString("")
		output.WriteString("System Info\n")
		output.WriteString("-----\n")
		err = status.SystemInfo(output)
		output.WriteString("\n")

		directoriesToCheck := []string{"src", "bin"}
		output.WriteString("Directory Expectations\n")
		output.WriteString("-----\n")
		for _, dir := range directoriesToCheck {
			_ = status.CheckForDirectory(output, usrHomeDir, dir)
		}
		output.WriteString("\n")

		output.WriteString("Package Manager\n")
		output.WriteString("-----\n")
		err = status.PackageManager(output)

		output.WriteString("\n")

		fmt.Print(output)
	},
}

StatusCmd represents status command

Functions

func Execute

func Execute()

Execute comment for execute

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL