-
Notifications
You must be signed in to change notification settings - Fork 94
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 Progress Bar Helper #82
Add Progress Bar Helper #82
Conversation
This looks awesome! I will check it out locally soon. What are your thoughts on naming the function Also wondering whether we could support passing a |
Good call on the naming convention, I'll switch that out now (it was bothering me that it was cased differently than the others but didn't think to just shorten it to progress). And... yes to support a |
I've fixed the terminal width issue and also handled restoring the cursor when I also removed the |
Hey @joetannenbaum, I've made a few extra changes:
Keen to know your thoughts! I hope you don't mind me messing around with it - I just got quite excited about the possibilities 😁 |
Oh, I was also wondering about your thoughts on making the label optional. |
Glad to hear!
I agree. I think it's just because the existing progress bar doesn't have a label - it seems like it should be optional here. The main reason I'm bringing it up now is in case we need to change the param order to support it being optional.
Modifying the trait seems fine to me. Kinda feels like a bugfix for any prompt that uses it tbh.
I agree - it almost feels like you're doing something that wasn't intended. I've added a fluent
Thanks! I'm really digging this feature! Thanks for all your work! |
Optional labels: makes sense, totally. Let's do it. Do you want me to modify that trait? |
7c56839
to
9bd26c8
Compare
I'm having second thoughts about moving the label parameter 😅 It felt weird being anywhere other than the start. I've just pushed a change I'd love your thoughts on. It lets you skip the label if you're using positional arguments or named arguments, so you can do stuff like: progress(['one', 'two', 'three'], fn ($item) => strtoupper($item));
progress('Label', ['one', 'two', 'three'], fn ($item) => strtoupper($item));
progress(10, fn ($i) => $i);
$progress = progress(10);
$progress = progress(steps: 10);
// etc... |
So I really like the ergonomics of the examples you gave, but I'm a little concerned that the signature is now a bit confusing. It's not clear to me without heading to documentation that I would be able to do this, for example: progress(['one', 'two', 'three'], fn ($item) => strtoupper($item)); Is there a way we can make it clearer to the user about the positional variations they can use in the codebase itself? Or is this a case where the vast majority of users will use be using label anyways and they can discover the variations via the docs? I'm not sure. |
Totally agree. I was inspired by various methods in Laravel, but I don't think those have as many parameters to juggle. I'm not aware of a good way to express overloaded function signatures in PHP. If it were a class method, we could add multiple Maybe we should just go back to what you had with a mandatory I'll make that change shortly and see how it goes (unless you have any other ideas). Thanks for the feedback! |
Hey @joetannenbaum, Are you happy with where this landed? If so, I think we're good to open it for Taylor to review. Thanks again! |
Hey @jessarcher, I am happy with where this is at, thank you so much for all of your work on this! Do you feel good about it? I looked into some sort of I'm good with this if you're good, I think it looks super polished. Thanks again! |
Thanks for double-checking! Yeah, I'm really happy with where it's at. It can do everything that the existing progress bar can do and more, and it matches the style of Prompts. Fantastic addition! |
@joetannenbaum @jessarcher The only thing missing is some documentation ! Thanks |
This PR adds a progress bar helper. I modeled it largely after the existing Artisan progress bar with some minor alterations, primarily, that you can add optinoally label identifying the current item as the bar progresses.
I added a playground file so you can see the different options, it looks like the following:
CleanShot.2023-09-21.at.21.57.14.mp4
In terms of manual mode, I considered returning a different class with only the required public functions, but thought that might be over thinking it.