From 788113a94f9268be70796407b2de8d7f740af51b Mon Sep 17 00:00:00 2001 From: viniciussanchez Date: Mon, 10 Aug 2020 16:25:21 -0300 Subject: [PATCH] Option to initialize the boss with default values --- cmd/init.go | 5 ++++- consts/consts.go | 2 +- core/initializePackage.go | 27 +++++++++++++++++---------- installer/boss.iss | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 4ad67d6..68214c3 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -5,15 +5,18 @@ import ( "github.com/spf13/cobra" ) +var quiet bool + var initCmd = &cobra.Command{ Use: "init", Short: "Initialize a new project", Long: `This command initialize a new project`, Run: func(cmd *cobra.Command, args []string) { - core.InitializeBossPackage() + core.InitializeBossPackage(quiet) }, } func init() { RootCmd.AddCommand(initCmd) + initCmd.Flags().BoolVar(&quiet, "q", false, "Quiet") } diff --git a/consts/consts.go b/consts/consts.go index a555de3..8f15bfa 100644 --- a/consts/consts.go +++ b/consts/consts.go @@ -38,7 +38,7 @@ const XmlTagNamePropertyAttributeValue string = "'$(Base)'!=''" const XmlTagNameLibraryPath string = "DCC_UnitSearchPath" -const Version string = "v3.0.2" +const Version string = "v3.0.3" const BossInternalDir = "internal." const BossInternalDirOld = "{internal}" diff --git a/core/initializePackage.go b/core/initializePackage.go index 12ebb09..66e57b7 100644 --- a/core/initializePackage.go +++ b/core/initializePackage.go @@ -3,12 +3,13 @@ package core import ( "bufio" "fmt" - "github.com/hashload/boss/env" - "github.com/hashload/boss/models" "os" "path/filepath" "regexp" "strings" + + "github.com/hashload/boss/env" + "github.com/hashload/boss/models" ) func printHead() { @@ -38,7 +39,7 @@ func getParamOrDef(msg string, def string) string { return def } -func doInitialization() { +func doInitialization(quiet bool) { printHead() pkgJson, _ := models.LoadPackage(true) @@ -49,15 +50,21 @@ func doInitialization() { folderName = allString[0][1] } - pkgJson.Name = getParamOrDef("package name: ("+folderName+")", folderName) - pkgJson.Homepage = getParamOrDef("homepage", "") - pkgJson.Version = getParamOrDef("version: (1.0.0)", "1.0.0") - pkgJson.Description = getParamOrDef("description", "") - pkgJson.MainSrc = getParamOrDef("source folder: (./)", "./") + if quiet { + pkgJson.Name = folderName + pkgJson.Version = "1.0.0" + pkgJson.MainSrc = "./" + } else { + pkgJson.Name = getParamOrDef("package name: ("+folderName+")", folderName) + pkgJson.Homepage = getParamOrDef("homepage", "") + pkgJson.Version = getParamOrDef("version: (1.0.0)", "1.0.0") + pkgJson.Description = getParamOrDef("description", "") + pkgJson.MainSrc = getParamOrDef("source folder: (./)", "./") + } pkgJson.Save() } -func InitializeBossPackage() { - doInitialization() +func InitializeBossPackage(quiet bool) { + doInitialization(quiet) } diff --git a/installer/boss.iss b/installer/boss.iss index a8b763d..be94c9c 100644 --- a/installer/boss.iss +++ b/installer/boss.iss @@ -1,5 +1,5 @@ #define BossName "Boss" -#define BossVersion "3.0.2" +#define BossVersion "3.0.3" #define BossPublisher "Hashload" #define BossURL "https://github.com/HashLoad/boss"