use stdout() function instead of fmt.Println() in some places.

This commit is contained in:
fiatjaf 2024-09-21 12:02:09 -03:00
parent a4886dc445
commit 3215726417
2 changed files with 8 additions and 8 deletions

View File

@ -45,7 +45,7 @@ var encrypt = &cli.Command{
if err != nil {
return err
}
fmt.Println(ciphertext)
stdout(ciphertext)
} else {
ss, err := nip04.ComputeSharedSecret(target, sec)
if err != nil {
@ -55,7 +55,7 @@ var encrypt = &cli.Command{
if err != nil {
return fmt.Errorf("failed to encrypt as nip04: %w", err)
}
fmt.Println(ciphertext)
stdout(ciphertext)
}
} else {
kr, err := gatherKeyerFromArguments(ctx, c)
@ -67,7 +67,7 @@ var encrypt = &cli.Command{
if err != nil {
return fmt.Errorf("failed to encrypt: %w", err)
}
fmt.Println(res)
stdout(res)
}
return nil
@ -110,7 +110,7 @@ var decrypt = &cli.Command{
if err != nil {
return err
}
fmt.Println(plaintext)
stdout(plaintext)
} else {
ss, err := nip04.ComputeSharedSecret(source, sec)
if err != nil {
@ -120,7 +120,7 @@ var decrypt = &cli.Command{
if err != nil {
return fmt.Errorf("failed to encrypt as nip04: %w", err)
}
fmt.Println(plaintext)
stdout(plaintext)
}
} else {
kr, err := gatherKeyerFromArguments(ctx, c)
@ -132,7 +132,7 @@ var decrypt = &cli.Command{
if err != nil {
return fmt.Errorf("failed to encrypt: %w", err)
}
fmt.Println(res)
stdout(res)
}
return nil

4
key.go
View File

@ -252,13 +252,13 @@ However, if the intent is to check if two existing Nostr pubkeys match a given c
}
res, _ := json.MarshalIndent(result, "", " ")
fmt.Println(string(res))
stdout(string(res))
return nil
},
}
func getSecretKeysFromStdinLinesOrSlice(ctx context.Context, c *cli.Command, keys []string) chan string {
func getSecretKeysFromStdinLinesOrSlice(ctx context.Context, _ *cli.Command, keys []string) chan string {
ch := make(chan string)
go func() {
for sec := range getStdinLinesOrArgumentsFromSlice(keys) {