From b8213eba24f1fed956a8a34dc189544dba4bee96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8E=9A=E4=BC=9F?= Date: Thu, 26 Nov 2020 14:15:00 +0800 Subject: [PATCH] add InitToml and fmt code --- cmd/commands/beefix/fix.go | 2 +- cmd/commands/beefix/fix1To2.go | 4 ++-- cmd/commands/beefix/fixTo1.6.go | 3 +-- internal/app/module/beegopro/container.go | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/cmd/commands/beefix/fix.go b/cmd/commands/beefix/fix.go index 5090881..9cde22e 100644 --- a/cmd/commands/beefix/fix.go +++ b/cmd/commands/beefix/fix.go @@ -36,7 +36,7 @@ func init() { func runFix(cmd *commands.Command, args []string) int { t := target.String() - if t == "" || t == "1.6"{ + if t == "" || t == "1.6" { return fixTo16(cmd, args) } else if strings.HasPrefix(t, "2") { // upgrade to v2 diff --git a/cmd/commands/beefix/fix1To2.go b/cmd/commands/beefix/fix1To2.go index 28365f7..30cd06b 100644 --- a/cmd/commands/beefix/fix1To2.go +++ b/cmd/commands/beefix/fix1To2.go @@ -1,4 +1,4 @@ -// Copyright 2020 +// Copyright 2020 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -46,4 +46,4 @@ func runShell(cmdStr string) error { return err } return nil -} \ No newline at end of file +} diff --git a/cmd/commands/beefix/fixTo1.6.go b/cmd/commands/beefix/fixTo1.6.go index 8e38f67..400ad1e 100644 --- a/cmd/commands/beefix/fixTo1.6.go +++ b/cmd/commands/beefix/fixTo1.6.go @@ -1,4 +1,4 @@ -// Copyright 2020 +// Copyright 2020 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -228,4 +228,3 @@ func fixFile(file string) error { } return ioutil.WriteFile(file, []byte(fixed), 0666) } - diff --git a/internal/app/module/beegopro/container.go b/internal/app/module/beegopro/container.go index 69c9084..b579671 100644 --- a/internal/app/module/beegopro/container.go +++ b/internal/app/module/beegopro/container.go @@ -208,3 +208,21 @@ func (c *Container) flushTimestamp() { beeLogger.Log.Fatalf("flush timestamp tmpl parse error, err: %s", err) } } + +func (c *Container) InitToml() { + if exist := utils.IsExist(c.BeegoProFile); exist { + beeLogger.Log.Fatalf("file beegopro.toml already exists") + } + sourceFile := c.UserOption.GitLocalPath + "/beegopro.toml" + input, err := ioutil.ReadFile(sourceFile) + if err != nil { + beeLogger.Log.Fatalf("read beegopro.toml file err, %s", err.Error()) + return + } + err = ioutil.WriteFile(c.BeegoProFile, input, 0644) + if err != nil { + beeLogger.Log.Fatalf("create beegopro.toml file err, %s", err.Error()) + return + } + beeLogger.Log.Success("Successfully created file beegopro.toml") +} \ No newline at end of file