Open olivertzeng opened 2 years ago
Hey this is a great idea, how would you want to pass the progress information to the progress bar? I.e. how does the progress bar know when to progress? Or would it act similar to a spinner?
It's probably not a spinner, its a thing that's called the --gauge
flag in dialog
.
I also would like for the progress bar to exist, as this would make some scripts just a tiny bit nicer. Given that bubbles already has a progress bar one just needs to define how the command should work, which is what follows...
$ gum progress --help
Usage: gum progress
Display a progress bar given some input from standard input.
The progress is counted up whenever the --progress-indicator is encountered.
Flags:
-h, --help Show context-sensitive help.
-v, --version Print the version number
-l, --limit Specify how many items there are
-t, --title Some contextual information which is shown to the user
-i, --progress-indicator What indicator to use for counting progress. Defaults to '\n'
-h, --hide-progress-indicator Don't re-print the progress indicator
-o, --show-output Forward the input
sleep used as placeholder for any 'long' running process
The best case scenario is that we know the limit and can therefore show a nice progress bar.
amount='5'
for i in $(seq "$amount"); do
sleep 1s
echo ""
done | gum progress --limit "$amount" --title 'Counting the stars'
Given that the length is unknown we could still show how many iterations have passed and also show the elapsed time.
tqdm does it like this like so: 2it [00:20, 2.00s/it]
find / -name ice.cream | gum progress --show-output
while true; do
if [[ some cond ]]; then
break
fi
sleep 1s
echo ""
done | gum progress
When some commands run that also output something which should stay undisturbed but progress should still be shown the following could be done
{
sleep 1s
echo ':step:'
sleep 1s
echo ':step:'
} | gum progress --limit 2 --progress-indicator ':step:' --hide-progress-indicator
What do you think? Is this something that would fit gum? I'd actually like to work on this. Ping @muesli @maaslalani as both of you were already active in that issue.
As answer to the question: a new-line character on default.
I also would like for the progress bar to exist, as this would make some scripts just a tiny bit nicer. Given that bubbles already has a progress bar one just needs to define how the command should work, which is what follows...
The help of the command
$ gum progress --help Usage: gum progress Display a progress bar given some input from standard input. The progress is counted up whenever the --progress-indicator is encountered. Flags: -h, --help Show context-sensitive help. -v, --version Print the version number -l, --limit Specify how many items there are -t, --title Some contextual information which is shown to the user -i, --progress-indicator What indicator to use for counting progress. Defaults to '\n' -h, --hide-progress-indicator Don't re-print the progress indicator -o, --show-output Forward the input
Some examples
sleep used as placeholder for any 'long' running process
Known length
The best case scenario is that we know the limit and can therefore show a nice progress bar.
amount='5' for i in $(seq "$amount"); do sleep 1s echo "" done | gum progress --limit "$amount" --title 'Counting the stars'
Unknown length
Given that the length is unknown we could still show how many iterations have passed and also show the elapsed time.
tqdm does it like this like so:
2it [00:20, 2.00s/it]
find / -name ice.cream | gum progress --show-output
while true; do if [[ some cond ]]; then break fi sleep 1s echo "" done | gum progress
Special indicator for progress
When some commands run that also output something which should stay undisturbed but progress should still be shown the following could be done
{ sleep 1s echo ':step:' sleep 1s echo ':step:' } | gum progress --limit 2 --progress-indicator ':step:' --hide-progress-indicator
What do you think? Is this something that would fit gum? I'd actually like to work on this.
Ping @muesli @maaslalani as both of you were already active in that issue.
As answer to the question: a new-line character on default.
Thanks for your reply!
Would really want to see this feature being implemented Lu
Is your feature request related to a problem? Please describe. I actually want to make a good Arch Linux install script but the gum spin doesn't show progress[...]
Describe the solution you'd like Add a --progress-bar or -p (checkout dialog)
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.