You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking at issue #11 which was attempted to be fixed with #20. The change wasn't landed because of the difference in launching PowerShell file and a script block. My particular use case is mainly around files with parameters, so I'm looking at how this would work.
What do you think about a builder approach where you need to specify script or file, which can then allow for args only when you're going to run a file?
If this seems acceptable, I'd be happy to work on a PR
Something like
fn main() {
let ps = PsScriptBuilder::new()
.no_profile(true)
.non_interactive(true)
.hidden(false)
.print_commands(false)
.file("path/to/file.ps1")
.arguments.add("argument")
.build();
// below fails
let output = ps.run(r#"echo "hello world""#).unwrap();
// below works
let output = ps.run().unwrap();
}
likewise
fn main() {
let ps = PsScriptBuilder::new()
.no_profile(true)
.non_interactive(true)
.hidden(false)
.print_commands(false)
.build();
// below works
let output = ps.run(r#"echo "hello world""#).unwrap();
// below fails
let output = ps.run().unwrap();
}
I think it would be better to have both approaches specify the payload (file or script) in the builder methods, but that would conflict with how it works currently.
The text was updated successfully, but these errors were encountered:
I think this might be a good idea. I think this will be a breaking change anyway, but if we end up with a better API I think it's worth it. Since there seems to be quite a bit of interest for this I think the solution you suggest seems fine and I would really appreciate any help I can get on this.
I was looking at issue #11 which was attempted to be fixed with #20. The change wasn't landed because of the difference in launching PowerShell file and a script block. My particular use case is mainly around files with parameters, so I'm looking at how this would work.
What do you think about a builder approach where you need to specify script or file, which can then allow for args only when you're going to run a file?
If this seems acceptable, I'd be happy to work on a PR
Something like
likewise
I think it would be better to have both approaches specify the payload (file or script) in the builder methods, but that would conflict with how it works currently.
The text was updated successfully, but these errors were encountered: