-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: add support for remaining args #82
feat: add support for remaining args #82
Conversation
Fun.Build/StageContextExtensions.fs
Outdated
member ctx.GetRemainingsCmdArgs() = | ||
match ctx.ParentContext with | ||
| ValueSome(StageParent.Pipeline p) -> p.RemainingCmdArgs | ||
| ValueSome(StageParent.Stage s) -> s.GetRemainingsCmdArgs() |
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.
Is the "s" after Remaining necessary? My English is not well to know that. But I see in the PipelineContext you are not using s for RemainingCmdArgs, so just wandering.
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.
Good catch.
I checked and Spectre.Console.Cli use Remaining
for the name of property.
One less letter to type is always good 😊
@@ -499,6 +499,23 @@ module StageContextExtensions = | |||
| ValueSome(StageParent.Stage s) -> s.GetAllCmdArgs() |
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.
Can we add some comments on the GetAllCmdArgs to identify it will not return the remaing ones?
@MangelMaxime for the unit test, I think you can write code like: let mutable actualAllCmdArgs = []
let mutable actualRemainingArgs = []
pipeline "demo" {
cmdArgs ["-p"; "demo"; "test1"; "v1"; "--"; "test2"; "v2"]
stage "shows arguments" {
run (fun ctx ->
actualAllCmdArgs <- ctx.GetAllCmdArgs()
actualRemainingArgs <- ctx.GetRemainingsCmdArgs()
)
}
runImmediate
}
// Assert accordingly
|
Regarding the unit test, originally I wrote something like you suggested but in the middle of writing this PR I changed how I implemented I will give it a try and check what happens. |
I checked and with my current implementation I can't test it the way you proposed. However, looking at the comment in the code, I think I should also add the Args/Remaining split logic at this place too no? Fun.Build/Fun.Build/PipelineBuilder.fs Lines 174 to 181 in bedb12f
|
Yes, I think we should do that. |
65341c1
to
cb963f6
Compare
@albertwoo This is ready for review. By using making |
The failing test doesn't seem related to my changes but caused by a slow CI runner. |
The failing test is related to a paralle tests, existing before, but did not figure out why 😂. I will merge your PR, thanks for your contribution. |
I don't know how to make this change testable because it happens at the creation of the
Pipeline
so I added a demo script to showcase what it does and as an easy way to check that all is good for you.One idea for making it testable was to change:
Fun.Build/Fun.Build/PipelineContextExtensions.fs
Lines 13 to 15 in 3053b5e
to
but I don't think this is good idea to change an API just to make it testable. Because I don't think we ever want to override the
Environment.GetCommandLineArgs()
in a normal usage.