feat(*): dryRun/debug mode/mode plugins/googleapis

Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
storyicon 2021-07-21 20:25:38 +08:00
parent 9aac714c32
commit da77c8086d
No known key found for this signature in database
GPG key ID: 245915D985F966CF
26 changed files with 730 additions and 126 deletions

View file

@ -23,8 +23,8 @@ import (
"github.com/pkg/errors"
"github.com/storyicon/powerproto/pkg/consts"
"github.com/storyicon/powerproto/pkg/util"
"github.com/storyicon/powerproto/pkg/util/command"
"github.com/storyicon/powerproto/pkg/util/logger"
)
@ -59,15 +59,21 @@ func ActionReplace(ctx context.Context, log logger.Logger, args []string, option
panic(err)
}
if matched {
if command.IsDryRun(ctx) {
if consts.IsDryRun(ctx) {
log.LogInfo(map[string]interface{}{
"action": "replace",
"file": path,
"from": from,
"to": to,
}, "DryRun")
}, consts.TextDryRun)
return nil
}
log.LogDebug(map[string]interface{}{
"action": "replace",
"file": path,
"from": from,
"to": to,
}, consts.TextExecuteAction)
data, err := ioutil.ReadFile(path)
if err != nil {
return err