-
Notifications
You must be signed in to change notification settings - Fork 348
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
434 Add Command to Tail -n Lines #544
base: main
Are you sure you want to change the base?
434 Add Command to Tail -n Lines #544
Conversation
Hey @CodeZea1ot, thanks so much for the contribution! What benefit do you get with |
Hey there @maaslalani The idea behind a For example, say you have a script that runs an install or download process that you don't want to hide with In other words, you would get up to Recording.2024-04-22.181848.mp4 |
I have to say, that's one of the features I'm waiting for so that I can start to use it. My usecase is a local dev environment in which several automated steps are performed to simplify the dev process. in my case, I would love exactly that for my build script, which should: build the code, create a test environment (databases with fixtures,...), then start the application and then run the end to end tests. Each of these steps produces output, which I don't want the whole screen to pollute. at the same time, it would be very useful for the developers to get a glimpse on what's going on (e.g. if there is an error in the build, or the application crashes at startup). Filling the whole screen with that just feels too verbose, yet not showing at all leaves the user without any sense of real progress. |
I built a BASH CLI called This is the functionality I'd like to bring to a |
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.
made some suggestions
also would be good to run goimports/gofmt
// Tail | ||
// Provides a means of streaming -n of lines from stdin |
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.
// Tail | |
// Provides a means of streaming -n of lines from stdin | |
// Tail provides a means of streaming a number of lines from stdin. |
@@ -196,6 +197,13 @@ type Gum struct { | |||
// | |||
Table table.Options `cmd:"" help:"Render a table of data"` | |||
|
|||
// Tail | |||
// Provides a means of streaming -n of lines from stdin | |||
// Useful for showing a subset of output from a process without clogging up the terminal |
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.
// Useful for showing a subset of output from a process without clogging up the terminal | |
// It is useful for showing a subset of output from a process without clogging up the terminal. |
// Provides a means of streaming -n of lines from stdin | ||
// Useful for showing a subset of output from a process without clogging up the terminal | ||
// | ||
// $ { sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y; } | gum tail -n 3 |
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.
// $ { sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y; } | gum tail -n 3 | |
// Let's watch apt update: | |
// | |
// $ { sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y; } | gum tail -n 3 |
"os" | ||
) | ||
|
||
// Run executes the tail command |
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.
// Run executes the tail command | |
// Run executes the tail command. |
} | ||
|
||
func clearScreen() { | ||
fmt.Print("\033[H\033[2J") |
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.
fmt.Print("\033[H\033[2J") | |
fmt.Print(ansi.EraseDisplay(2)) |
start := len(lines) - n | ||
if start < 0 { | ||
start = 0 | ||
} | ||
for i := start; i < len(lines); i++ { | ||
fmt.Println(lines[i]) | ||
} |
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.
start := len(lines) - n | |
if start < 0 { | |
start = 0 | |
} | |
for i := start; i < len(lines); i++ { | |
fmt.Println(lines[i]) | |
} | |
fmt.Println(strings.Join(lines, "\n")) |
Closes #434
Changes
gum tail
subcommandExample