Skip to content
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

Add command to tail n lines of output #434

Open
amancevice opened this issue Sep 28, 2023 · 6 comments · May be fixed by #544
Open

Add command to tail n lines of output #434

amancevice opened this issue Sep 28, 2023 · 6 comments · May be fixed by #544
Labels
enhancement New feature or request

Comments

@amancevice
Copy link

Is your feature request related to a problem? Please describe.

I'd love a new gum command that allows a user to stream the last n lines of output — very much like how Docker displays steps in the build process.

Describe the solution you'd like

I think the following would be an intuitive interface for users to show the 12 most recent lines of output of brew upgrade:

brew upgrade | gum stream --lines 12 --faint --italic # etc …

Describe alternatives you've considered

I'm not really sure how else to do this on the command line. I suppose a curses library could do it but that's not super convenient

Additional context

N/A

@4Ply
Copy link

4Ply commented Oct 7, 2023

gum style can do this using the tail command:

brew upgrade | tail -n 10 | gum style --faint --italic

@amancevice
Copy link
Author

amancevice commented Oct 7, 2023

@4Ply thanks but that doesn't stream the results, it just shows the last 10 lines of the brew upgrade

Docker's build command is a great example of what I'm after. Consider:

cat <<-DOCKERFILE | docker build -
FROM debian
RUN apt-get update && apt-get install -y ruby
DOCKERFILE

When Docker build gets to the RUN statement it streams the output as its running

@ZOrfeas
Copy link

ZOrfeas commented Oct 31, 2023

I looked around a bit for this, maybe it would fit as added functionality to gum pager? Sort of like how less does it with F since a few versions now.

@bashbunni bashbunni added the enhancement New feature or request label Oct 31, 2023
@ZOrfeas
Copy link

ZOrfeas commented Dec 14, 2023

I've been thinking of trying to implement this functionality for gum pager over christmas.

  1. Are you open to merge requests from general public?
  2. is this a good place to start?
    (the idea is to add another function for consuming the stdin as a stream, maybe via a channel)
  3. Would you think it's best for this to be a command line argument, a command within the pager interface, both ?

@YoungOak
Copy link

Dang, what @ZOrfeas mentioned would be so appreciated! Been testing different ways to try and stream stdout logs from a running api and was sad gum isn't able to handle it.

@amancevice
Copy link
Author

For what it's worth, I was able to achieve what I wanted in pure bash: https://github.com/amancevice/spin

@CodeZea1ot CodeZea1ot linked a pull request Apr 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants