Skip to content

Commit

Permalink
Add a flag to trim whitespace when encrypting
Browse files Browse the repository at this point in the history
  • Loading branch information
rbvigilante committed Nov 27, 2019
1 parent 279a408 commit 8130436
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ func main() {
{
Name: "encrypt",
Usage: "Encrypt with a KMS key",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "trim, t",
Usage: "If set, remove leading and trailing whitespace from plaintext",
},
},
Action: func(c *cli.Context) {
if len(c.Args()) == 0 {
sys.Abort(sys.UsageError, "no key specified")
Expand All @@ -50,6 +56,9 @@ func main() {
if err != nil {
sys.Abort(sys.UsageError, err)
}
if(c.Bool("trim")) {
plaintext = strings.TrimSpace(plaintext)
}
ciphertext, err := handle.Encrypt(plaintext, key)
if err != nil {
sys.Abort(sys.KmsError, err)
Expand Down

0 comments on commit 8130436

Please sign in to comment.