mc icon indicating copy to clipboard operation
mc copied to clipboard

Use a pager for help output

Open vadmeste opened this issue 3 years ago • 9 comments

Description

Automatically use a pager for the help

Depends on https://github.com/minio/cli/pull/8

Motivation and Context

Add pagination when printing long help message

How to test this PR?

mc cp -h

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Optimization (provides speedup with no functional changes)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ ] Fixes a regression (If yes, please add commit-id or PR # here)
  • [ ] Unit tests added/updated
  • [ ] Internal documentation updated
  • [ ] Create a documentation update request here

vadmeste avatar Sep 13 '22 09:09 vadmeste

@vadmeste Would you mind if I try to implement without invoking less?

klauspost avatar Sep 13 '22 10:09 klauspost

@vadmeste Would you mind if I try to implement without invoking less?

No problem, do you know any good library for that ? also I found this PR doesn't work in some cases, unfortunately the cli library calls os.Exit() in certain cases, this is maybe not easy to implement

vadmeste avatar Sep 13 '22 10:09 vadmeste

Yeah, os.Exit is always going to be a problem. So this only for help (for now?)

While a full 'less' would be great, maybe just paging would be fine.

External programs are always going to be flaky, so while it has the upside of all the "less" features, if they need that then mc --help|less is the way to go.

klauspost avatar Sep 13 '22 10:09 klauspost

Rather than using less you can use this https://github.com/charmbracelet/bubbletea/tree/master/examples/pager @vadmeste

harshavardhana avatar Sep 15 '22 09:09 harshavardhana

Rather than using less you can use this https://github.com/charmbracelet/bubbletea/tree/master/examples/pager @vadmeste

Yes, I didn't see this when I went through their docs, will try it out

vadmeste avatar Sep 15 '22 09:09 vadmeste

I made some progress, the code currently is little bit complex because I had to connect cli with bubbletea but overall it is fine, can you test this @harshavardhana before I make the remaining changes ? hopefully no surprises after that

vadmeste avatar Sep 15 '22 20:09 vadmeste

It works fine @vadmeste however we have to show how to quit at the bottom page otherwise users won't know how to quit the pager.

harshavardhana avatar Sep 15 '22 22:09 harshavardhana

It works fine @vadmeste however we have to show how to quit at the bottom page otherwise users won't know how to quit the pager.

okay, there are still more edge cases that I need to address, they should be fixed today

vadmeste avatar Sep 16 '22 07:09 vadmeste

This PR https://github.com/minio/cli/pull/9/files is also needed. Otherwise all of this won't work :)

vadmeste avatar Sep 19 '22 09:09 vadmeste

PTAL at the conflict @vadmeste

harshavardhana avatar Sep 27 '22 22:09 harshavardhana

Is there an option included to disable this?

It's pretty cumbersome if the help output disappears while you're trying to cobble together a command with multiple flags and one can't look at the output history because it disappears with the pager.

mc cp -h | cat is a dumb workaround.

zeeZ avatar Oct 08 '22 21:10 zeeZ

We are going to fix the pager for it to stay the output..

harshavardhana avatar Oct 09 '22 00:10 harshavardhana

Is there an option included to disable this?

@zeeZ I think you want this PR, https://github.com/minio/mc/pull/4289, it keeps the help screen after quitting it

vadmeste avatar Oct 09 '22 13:10 vadmeste