I propose to inject the spinner instance as an optional parameter to functions decorated by halo. This was my use case:
@Halo(text='Doing work', spinner='dots', color="red")
def initialize_git(spinner=None): # This argument is optional and can also be omitted
try:
my_complicated_function()
except Exception:
spinner.fail("Failed!")
raise
spinner.succeed("Succeeded!")
I know that this is possible to use a context manager, but this does require deeper nesting and is not that neat imo. Please let me know if you consider this a valid use case.
Description
This PR adds functionality to declare the optional keyword argument as a parameter to obtain a reference to the spinner object. This does not break anything and is completely optional.
Checklist
[x] Your branch is up-to-date with the base branch
[x] You've included at least one test if this is a new feature
[x] All tests are passing
Further considerations
It is also possible to inject the spinner instance as a positional argument, but this could not be made optional.
I propose to inject the spinner instance as an optional parameter to functions decorated by halo. This was my use case:
I know that this is possible to use a context manager, but this does require deeper nesting and is not that neat imo. Please let me know if you consider this a valid use case.
Description
This PR adds functionality to declare the optional keyword argument as a parameter to obtain a reference to the spinner object. This does not break anything and is completely optional.
Checklist
Further considerations
It is also possible to inject the spinner instance as a positional argument, but this could not be made optional.