Skip to content

Commit 0e188e2

Browse files
committed
fix: make silent global flag instead of only for claims
1 parent 16315b5 commit 0e188e2

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

pkg/internal/common/flags/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ func GetSignerFlags() []cli.Flag {
1414
&FireblocksTimeoutFlag,
1515
&FireblocksSecretStorageTypeFlag,
1616
&Web3SignerUrlFlag,
17+
&SilentFlag,
1718
}
1819
}

pkg/internal/common/flags/general.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,11 @@ var (
7575
Usage: "Enable verbose logging",
7676
EnvVars: []string{"VERBOSE"},
7777
}
78+
79+
SilentFlag = cli.BoolFlag{
80+
Name: "silent",
81+
Aliases: []string{"s"},
82+
Usage: "Suppress unnecessary output (except for claim data to enable piping)",
83+
EnvVars: []string{"SILENT"},
84+
}
7885
)

pkg/internal/common/helper.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"io"
89
"log/slog"
910
"math/big"
1011
"os"
@@ -445,6 +446,11 @@ func IsEmptyString(s string) bool {
445446

446447
func GetLogger(cCtx *cli.Context) eigensdkLogger.Logger {
447448
verbose := cCtx.Bool(flags.VerboseFlag.Name)
449+
450+
if cCtx.Bool(flags.SilentFlag.Name) {
451+
return eigensdkLogger.NewTextSLogger(io.Discard, nil)
452+
}
453+
448454
loggerOptions := &eigensdkLogger.SLoggerOptions{
449455
Level: slog.LevelInfo,
450456
}

pkg/rewards/claim.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8-
"io"
98
"math/big"
109
"net/http"
1110
"sort"
@@ -75,7 +74,6 @@ func getClaimFlags() []cli.Flag {
7574
&ClaimTimestampFlag,
7675
&ProofStoreBaseURLFlag,
7776
&flags.VerboseFlag,
78-
&SilentFlag,
7977
}
8078

8179
allFlags := append(baseFlags, flags.GetSignerFlags()...)
@@ -87,10 +85,6 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
8785
ctx := cCtx.Context
8886
logger := common.GetLogger(cCtx)
8987

90-
if cCtx.Bool(SilentFlag.Name) {
91-
logger = logging.NewTextSLogger(io.Discard, nil)
92-
}
93-
9488
config, err := readAndValidateClaimConfig(cCtx, logger)
9589
if err != nil {
9690
return eigenSdkUtils.WrapError("failed to read and validate claim config", err)
@@ -246,24 +240,31 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
246240
logger.Infof("Claim written to file: %s", config.Output)
247241
} else {
248242
fmt.Println(string(jsonData))
249-
logger.Info("To write to a file, use the --output flag")
243+
fmt.Println()
244+
fmt.Println("To write to a file, use the --output flag")
250245
}
251246
} else {
252247
if !common.IsEmptyString(config.Output) {
253-
logger.Info("output file not supported for pretty output type")
248+
fmt.Println("output file not supported for pretty output type")
249+
fmt.Println()
254250
}
255251
solidityClaim := claimgen.FormatProofForSolidity(accounts.Root(), claim)
256-
logger.Info("------- Claim generated -------")
252+
if !config.IsSilent {
253+
fmt.Println("------- Claim generated -------")
254+
}
257255
common.PrettyPrintStruct(*solidityClaim)
258-
logger.Info("-------------------------------")
259-
logger.Info("To write to a file, use the --output flag")
256+
if !config.IsSilent {
257+
fmt.Println("-------------------------------")
258+
fmt.Println("To write to a file, use the --output flag")
259+
}
260260
}
261-
if !cCtx.Bool(SilentFlag.Name) {
261+
if !config.IsSilent {
262262
txFeeDetails := common.GetTxFeeDetails(unsignedTx)
263-
logger.Info("\n")
263+
fmt.Println()
264264
txFeeDetails.Print()
265+
266+
fmt.Println("To broadcast the claim, use the --broadcast flag")
265267
}
266-
logger.Info("To broadcast the claim, use the --broadcast flag")
267268
}
268269

269270
return nil
@@ -372,6 +373,7 @@ func readAndValidateClaimConfig(cCtx *cli.Context, logger logging.Logger) (*Clai
372373
splitTokenAddresses := strings.Split(tokenAddresses, ",")
373374
validTokenAddresses := getValidHexAddresses(splitTokenAddresses)
374375
rewardsCoordinatorAddress := cCtx.String(RewardsCoordinatorAddressFlag.Name)
376+
isSilent := cCtx.Bool(SilentFlag.Name)
375377

376378
var err error
377379
if common.IsEmptyString(rewardsCoordinatorAddress) {
@@ -455,6 +457,7 @@ func readAndValidateClaimConfig(cCtx *cli.Context, logger logging.Logger) (*Clai
455457
SignerConfig: signerConfig,
456458
ClaimTimestamp: claimTimestamp,
457459
ClaimerAddress: claimerAddress,
460+
IsSilent: isSilent,
458461
}, nil
459462
}
460463

pkg/rewards/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type ClaimConfig struct {
3030
ProofStoreBaseURL string
3131
Environment string
3232
SignerConfig *types.SignerConfig
33+
IsSilent bool
3334
}
3435

3536
type SetClaimerConfig struct {

0 commit comments

Comments
 (0)