Skip to content

Commit

Permalink
remove HasFlag (does not work), and make default num lines = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
christophercampbell committed Jan 30, 2025
1 parent 0bac795 commit c04c7f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 0 additions & 5 deletions cli/cli/command_framework/lowlevel/flags/parsed_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,3 @@ func (flags *ParsedFlags) GetBool(name string) (bool, error) {
}
return value, nil
}

func (flags *ParsedFlags) HasFlag(name string) bool {
_, err := flags.cmdFlagsSet.GetString(name)
return err != nil
}
10 changes: 5 additions & 5 deletions cli/cli/commands/service/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (

interruptChanBufferSize = 5

defaultNumLogLines = 200
defaultNumLogLines = 0
commonInstructionInMatchFlags = "Important: " + matchTextFilterFlagKey + " and " + matchRegexFilterFlagKey + " flags cannot be used at the same time. You should either use one or the other."
)

Expand Down Expand Up @@ -195,10 +195,6 @@ func run(
return stacktrace.Propagate(err, "An error occurred getting the should-follow-logs flag using key '%v'", shouldFollowLogsFlagKey)
}

if shouldFollowLogs && flags.HasFlag(returnNumLogsFlagKey) {
return stacktrace.Propagate(stacktrace.NewError("Unsupported flags combination"), "`%v` flag cannot be used with `%v` flag", shouldFollowLogsFlagKey, returnNumLogsFlagKey)
}

shouldReturnAllLogs, err := flags.GetBool(returnAllLogsFlagKey)
if err != nil {
return stacktrace.Propagate(err, "An error occurred getting the 'all' flag using key '%v'", returnAllLogsFlagKey)
Expand All @@ -209,6 +205,10 @@ func run(
return stacktrace.Propagate(err, "An error occurred getting the 'num' flag using key '%v'", returnNumLogsFlagKey)
}

if shouldFollowLogs && numLogLines > 0 {
return stacktrace.Propagate(stacktrace.NewError("Unsupported flags combination"), "`%v` flag cannot be used with `%v` flag", shouldFollowLogsFlagKey, returnNumLogsFlagKey)
}

matchTextStr, err := flags.GetString(matchTextFilterFlagKey)
if err != nil {
return stacktrace.Propagate(err, "An error occurred getting the match flag using key '%v'", matchTextFilterFlagKey)
Expand Down

0 comments on commit c04c7f0

Please sign in to comment.