Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Apr 29, 2024
1 parent a1a1737 commit 64eea09
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
### Features

* [#1406](https://github.com/crypto-org-chain/cronos/pull/1406) Add set-encryption-key for encryption module.
* [#](https://github.com/crypto-org-chain/cronos/pull/) Add encrypt and decrypt cmds for message.
* [#1411](https://github.com/crypto-org-chain/cronos/pull/1411) Add encrypt and decrypt cmds for message.

*April 8, 2024*

Expand Down
6 changes: 5 additions & 1 deletion cmd/cronosd/cmd/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func DecryptMsgCommand() *cobra.Command {
if err != nil {
return err
}
defer f.Close()
defer func() {
if err := f.Close(); err != nil {
fmt.Println("file close error", err)
}
}()
in = f
}
return decrypt(inputs, in, out)
Expand Down
14 changes: 11 additions & 3 deletions cmd/cronosd/cmd/encrypt.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"io"
"os"

Expand Down Expand Up @@ -35,20 +36,27 @@ func EncryptMsgCommand() *cobra.Command {
if err != nil {
return err
}
defer f.Close()
defer func() {
if err := f.Close(); err != nil {
fmt.Println("file close error", err)
}
}()
in = f
}
if name := output; name != "" && name != "-" {
f := newLazyOpener(name)
defer f.Close()
defer func() {
if err := f.Close(); err != nil {
fmt.Println("file close error", err)
}
}()
out = f
}
return encrypt(recs, in, out)
},
}
f := cmd.Flags()
f.StringArray(flagR, []string{}, "recipient (can be repeated)")
f.StringArray(flagI, []string{}, "identity (can be repeated)")
f.String(flagO, "", "output to `FILE`")
return cmd
}
Expand Down
8 changes: 5 additions & 3 deletions cmd/cronosd/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"fmt"
"os"
"time"

"filippo.io/age"
"github.com/spf13/cobra"
Expand All @@ -26,7 +25,11 @@ func KeygenCommand() *cobra.Command {
if err != nil {
return err
}
defer f.Close()
defer func() {
if err := f.Close(); err != nil {
fmt.Println("file close error", err)
}
}()
out = f
}
return generate(out)
Expand All @@ -42,7 +45,6 @@ func generate(out *os.File) error {
return err
}
pubkey := k.Recipient()
fmt.Fprintf(out, "# created: %s\n", time.Now().Format(time.RFC3339))
fmt.Fprintf(out, "# public key: %s\n", pubkey)
fmt.Fprintf(out, "%s\n", k)
fmt.Println(pubkey)
Expand Down

0 comments on commit 64eea09

Please sign in to comment.