add force flag to re-encrypt even if data hasn't changed
This commit is contained in:
parent
9c0c3ee788
commit
e96bac3d9d
|
@ -66,6 +66,15 @@ var (
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "force",
|
||||||
|
Usage: "Re-encrypt the file even if no changes have been made.",
|
||||||
|
Aliases: []string{"f"},
|
||||||
|
Action: func(ctx *cli.Context, b bool) error {
|
||||||
|
force_overwrite = b
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "log",
|
Name: "log",
|
||||||
Usage: "log level",
|
Usage: "log level",
|
||||||
|
@ -162,7 +171,8 @@ func action(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
logger.Debug("got data back from editor")
|
logger.Debug("got data back from editor")
|
||||||
|
|
||||||
if string(edited) == string(decrypted) {
|
// don't overwrite same data, unless specified
|
||||||
|
if string(edited) == string(decrypted) && !force_overwrite {
|
||||||
logger.Warn("No edits made, not writing " + output_file)
|
logger.Warn("No edits made, not writing " + output_file)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ var (
|
||||||
configFile string
|
configFile string
|
||||||
|
|
||||||
input_file, output_file string
|
input_file, output_file string
|
||||||
|
force_overwrite bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue