-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve user control of paging #373
Conversation
I haven't yet added a top level |
I've preferred not breaking/changing the existing default pager behavior over supporting the simplest pager but that may be worth reconsidering if we think running in a busybox environment is more likely. Also, I'm not sure how paging works on windows but this probably doesn't make the situation any worse. Possibly Windows has the |
cmd/tk/util.go
Outdated
} | ||
} else { | ||
fmt.Println(r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't print an io.Reader
, need to read first :)
Maybe put this the bottom of the func:
_, err := io.Copy(os.Stdout, r)
return err
Then also when the cmd fails, don't return but instead just do "nothing", so it automatically falls back to above code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! The proposed refactor sounds nice but changes the function signature for fPageln
and potentially for pageln
too. If that's cool, I'll go ahead and make this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with both fPageln
and pageln
returning errors, it should be up to the consumer to ignore them if applicable.
Also makes the control flow inside a bit simpler I guess
Signed-off-by: Jack Baldry <[email protected]>
Signed-off-by: Jack Baldry <[email protected]>
Signed-off-by: Jack Baldry <[email protected]>
Signed-off-by: Jack Baldry <[email protected]>
fe659b7
to
1934e55
Compare
Thanks for all the feedback @sh0rez. I think this is ready for a second pass now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!!
Have some nitpicks, feel free to ignore
cmd/tk/workflow.go
Outdated
if err := pageln(pretty.String()); err != nil { | ||
return err | ||
} | ||
|
||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's the last statement, no need for if-else, as returning err does the same thing
cmd/tk/util.go
Outdated
err := cmd.Run() | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be one line using if err := ...; err != nil
Signed-off-by: Jack Baldry <[email protected]>
e1ddda0
to
f25ffad
Compare
This allows users to avoid a pager by emptying out the
PAGER
environment variable (settingPAGER=""
), only defaulting toless
with posix flags (not supported by busyboxless
) ifPAGER
is unset.Closes #293