Closed malthe closed 2 years ago
@jborean93 not sure this is really a good idea. My use-case is that I wanted users to be able to easily have an "init script" such as:
> Set-PSDebug -Trace 1
And it seemed a little awkward with the composable interface.
I'm unsure how I feel about this one. The current setup is designed to replicate the PowerShell class to the best it can. The add_cmdlet
is already a convenience operation as you can't normally do overloading in a simple way that AddCommand
offers and the latter is reserved for when adding an actual Command
instance rather than just the string. This is certainly easier to do compared to before but even so I'm not 100% convinced before was even that hard to begin with.
ps = PowerShell(rp)
ps.add_cmdlet('My-Function').add_parameters({...}).add_statement()
# vs
ps.add_cmdlet('My-Function', parameters={...}, end_of_statement=True)
In fact end_of_statement
makes it longer than the original so you don't really save on typing there. I'm happy to be convinced otherwise but I'm somewhat leaning towards just keep it the same as the .NET API.
I suppose I could instead prepare a "canned" command, which could easily be imported and added to the pipeline.
debug = Command("Set-PSDebug", args=CommandParameter("Trace", 1), end_of_statement=True)
I'll go ahead and close out this pull request.
Codecov Report
99.60% <75.00%> (-0.06%)
99.60% <75.00%> (-0.06%)
99.60% <75.00%> (-0.06%)
99.57% <75.00%> (-0.06%)
99.57% <75.00%> (-0.06%)
98.33% <75.00%> (-0.06%)
99.60% <75.00%> (-0.07%)
99.60% <75.00%> (-0.06%)
99.60% <75.00%> (-0.07%)
Flags with carried forward coverage won't be shown. Click here to find out more.
99.71% <75.00%> (-0.29%)
Continue to review full report at Codecov.