From 56e61e3f5a75d874df677d02dd2a3028bac7fb1f Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Wed, 18 Jul 2018 13:44:29 +0200 Subject: [PATCH] Adding other dependencies to gopkg, moving code, fixing printf --- cmd/cosmos-sdk-cli/cmd/init.go | 46 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index 2008cb896..b44c2be34 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -8,15 +8,36 @@ import ( "strings" "github.com/cosmos/cosmos-sdk/version" + tmversion "github.com/tendermint/tendermint/version" "github.com/spf13/cobra" "path/filepath" ) +var remoteProjectPath string + func init() { initCmd.Flags().StringVarP(&remoteProjectPath, "project-path", "p", "", "Remote project path. eg: github.com/your_user_name/project_name") rootCmd.AddCommand(initCmd) } +var initCmd = &cobra.Command{ + Use: "init [ProjectName]", + Short: "Initialize your new cosmos zone", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Print("Thanks for choosing Cosmos-SDK to build your project.\n\n") + projectName := args[0] + shortProjectName := strings.ToLower(projectName) + remoteProjectPath = strings.ToLower(strings.TrimSpace(remoteProjectPath)) + if remoteProjectPath == "" { + remoteProjectPath = strings.ToLower(shortProjectName) + } + setupBasecoinWorkspace(shortProjectName, remoteProjectPath) + return nil + }, +} + + func resolveProjectPath(remoteProjectPath string) string { gopath := os.Getenv("GOPATH") if gopath == "" { @@ -57,10 +78,14 @@ func copyBasecoinTemplate(projectName string, projectPath string, remoteProjectP func createGopkg(projectPath string) { // Create gopkg.toml file dependencies := map[string]string{ - "github.com/cosmos/cosmos-sdk": version.Version, + "github.com/cosmos/cosmos-sdk": "=" + version.Version, + "github.com/stretchr/testify": "=1.2.1", + "github.com/spf13/cobra": "=0.0.1", + "github.com/spf13/viper": "=1.0.0", } overrides := map[string]string{ "github.com/golang/protobuf": "1.1.0", + "github.com/tendermint/tendermint": tmversion.Version, } contents := "" for dependency, version := range dependencies { @@ -106,23 +131,6 @@ func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) createGopkg(projectPath) createMakefile(projectPath) - fmt.Println("\nInitialized a new project at " + projectPath + ".\nHappy hacking!") + fmt.Printf("\nInitialized a new project at %s.\nHappy hacking!\n", projectPath) } -var remoteProjectPath string -var initCmd = &cobra.Command{ - Use: "init [ProjectName]", - Short: "Initialize your new cosmos zone", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - fmt.Print("Thanks for choosing Cosmos-SDK to build your project.\n\n") - projectName := args[0] - shortProjectName := strings.ToLower(projectName) - remoteProjectPath = strings.ToLower(strings.TrimSpace(remoteProjectPath)) - if remoteProjectPath == "" { - remoteProjectPath = strings.ToLower(shortProjectName) - } - setupBasecoinWorkspace(shortProjectName, remoteProjectPath) - return nil - }, -}