Skip to content

Commit

Permalink
Option to initialize the boss with default values
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez committed Aug 10, 2020
1 parent c92c4cd commit 788113a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
5 changes: 4 additions & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
27 changes: 17 additions & 10 deletions core/initializePackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -38,7 +39,7 @@ func getParamOrDef(msg string, def string) string {
return def
}

func doInitialization() {
func doInitialization(quiet bool) {
printHead()
pkgJson, _ := models.LoadPackage(true)

Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion installer/boss.iss
Original file line number Diff line number Diff line change
@@ -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"

Expand Down

0 comments on commit 788113a

Please sign in to comment.