Adding other dependencies to gopkg, moving code, fixing printf

This commit is contained in:
Sridhar Ganesan 2018-07-18 13:44:29 +02:00
parent 9c5406891e
commit 56e61e3f5a
1 changed files with 27 additions and 19 deletions

View File

@ -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
},
}