Skip to content
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

Support for multi-line invocations without using parameter splatting or ` #11551

Closed
Pxtl opened this issue Jan 10, 2020 · 3 comments
Closed

Support for multi-line invocations without using parameter splatting or ` #11551

Pxtl opened this issue Jan 10, 2020 · 3 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-Duplicate The issue is a duplicate.

Comments

@Pxtl
Copy link

Pxtl commented Jan 10, 2020

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?

@Pxtl Pxtl added the Issue-Enhancement the issue is more of a feature request than a bug label Jan 10, 2020
@vexx32
Copy link
Collaborator

vexx32 commented Jan 10, 2020

@KirkMunro has some ideas and even an open PR handling something along these lines. Not sure we have consensus on what the solution ought to be here, but this seems to be an interesting idea to add to the possibilities.

@iSazonov
Copy link
Collaborator

Please discuss in the RFC PowerShell/PowerShell-RFC#179

@iSazonov iSazonov added the Resolution-Duplicate The issue is a duplicate. label Jan 11, 2020
@ghost
Copy link

ghost commented Jan 12, 2020

This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.

@ghost ghost closed this as completed Jan 12, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-Duplicate The issue is a duplicate.
Projects
None yet
Development

No branches or pull requests

3 participants