-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-DuplicateThe issue is a duplicate.The issue is a duplicate.
Description
Summary of the new feature/enhancement
Allow invocations that are wrapped in parentheses to span multiple lines, eg:
(Invoke-MyCommandlet
-arg1 "foo"
-arg2 "bar"
-arg3 "baz"
)Problem
Currently there are two dominant ways to do a multi-line invocation in powershell:
Backtick line-continuations
Invoke-MyCommandlet `
-arg1 "foo" `
-arg2 "bar" `
-arg3 "baz" `This is problematic because it's whitespace-sensitive and prevents using # for line-comments.
Splatting
$HashArguments = @{
arg1 = "foo"
arg2 = "bar"
arg3 = "baz"
}
Invoke-MyCommandlet @HashArguments this creates the problem that you lose intellisense and validation since you've decoupled the parameters from their corresponding command.
Summary
There are no good ways to do multiline invocations in Powershell.
Proposal
Let the humble parenthesis handle it. Currently, this:
(Invoke-MyCommandlet -arg1 "foo" -arg2 "bar" -arg3 "baz")is valid powershell, but this:
(Invoke-MyCommandlet
-arg1 "foo"
-arg2 "bar"
-arg3 "baz"
)is not valid. But why not? The open-parens clearly identifies that we're starting something that should not end until we see a close-parens. Why not, then, allow it to span multiple lines?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-DuplicateThe issue is a duplicate.The issue is a duplicate.