chore(*): format

Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
storyicon 2021-07-22 00:58:28 +08:00
parent 3bc2cede39
commit dc1e825e2b
No known key found for this signature in database
GPG key ID: 245915D985F966CF
16 changed files with 233 additions and 24 deletions

View file

@ -42,7 +42,7 @@ compile proto files and execute the post actions/shells:
powerproto build -r -a [dir]
`
// compile proto files
// CommandBuild is used to compile proto files
// powerproto build -r .
// powerproto build .
// powerproto build xxxxx.proto
@ -57,7 +57,13 @@ func CommandBuild(log logger.Logger) *cobra.Command {
Long: strings.TrimSpace(description),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
log.SetLogLevel(logger.LevelInfo)
ctx := cmd.Context()
if debugMode {
ctx = consts.WithDebugMode(ctx)
log.LogWarn(nil, "running in debug mode")
log.SetLogLevel(logger.LevelDebug)
}
if dryRun {
ctx = consts.WithDryRun(ctx)
log.LogWarn(nil, "running in dryRun mode")
@ -65,10 +71,6 @@ func CommandBuild(log logger.Logger) *cobra.Command {
if !postScriptEnabled {
ctx = consts.WithDisableAction(ctx)
}
if debugMode {
ctx = consts.WithDebugMode(ctx)
log.LogWarn(nil, "running in debug mode")
}
target, err := filepath.Abs(args[0])
if err != nil {

View file

@ -24,10 +24,10 @@ import (
"github.com/storyicon/powerproto/pkg/util/logger"
)
// Print environment variables related to program operation
// CommandEnv is used to print environment variables related to program operation
func CommandEnv(log logger.Logger) *cobra.Command {
return &cobra.Command{
Use: "env",
Use: "env",
Short: "list the environments and binary files",
Run: func(cmd *cobra.Command, args []string) {
log.LogInfo(nil, "[ENVIRONMENT]")
@ -41,7 +41,7 @@ func CommandEnv(log logger.Logger) *cobra.Command {
}
log.LogInfo(nil, "[BIN]")
for _, key := range []string {
for _, key := range []string{
"go",
"git",
} {

View file

@ -57,6 +57,7 @@ func tidy(ctx context.Context,
return nil
}
// CommandTidy is used to clean the config file
// By default, clean the powerproto.yaml of the current directory and all parent directories
// You can also explicitly specify the configuration file to clean up
func CommandTidy(log logger.Logger) *cobra.Command {
@ -66,7 +67,9 @@ func CommandTidy(log logger.Logger) *cobra.Command {
Short: "tidy the config file. It will replace the version number and install the protoc and proto plugins that declared in the config file",
Run: func(cmd *cobra.Command, args []string) {
ctx := cmd.Context()
log.SetLogLevel(logger.LevelInfo)
if debugMode {
log.SetLogLevel(logger.LevelDebug)
ctx = consts.WithDebugMode(ctx)
log.LogWarn(nil, "running in debug mode")
}