-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
DontShow should not hide common parameters #18472
Comments
Alternatively a change on L780 from false to true would be the simplest way to solve this PowerShell/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs Lines 772 to 781 in 9f459c0
However expanding on your proposed implementation this I think that if a |
I can see why someone might want to hide the 11 common parameters you get with cmdletbinding in simple functions/scripts that are meant to be used by less technical users. So I think it's best to have a replacement instead of just completely removing the option. |
For Simple scripts/functions you can do this by omitting the function Verb-Nounsimple {
Param
(
[string]
$Param1,
[string]
$Param2
)
} or also commonly written like so function Verb-Nounsimple { param([string]$Param1,[string]$Param2) } wont give you the common parameters in tab completion Same applies if you were to have a script with simple param block as per the above verb-nounsimple example - which is why I asked the question I did, because we already have the ability inbox, unless there really is a use case for the following
in which case the current design makes sense |
Sure you can, but then you miss out on pipeline support, parametersets, and mandatory parameters. |
Then you want an advanced function/script and not a simple function / script which again comes back to a more important question on function/script design. which is a much larger question than many realise until later on in the development of it & often changes drastically over time. |
So what's your point here? That nobody would want to hide the common parameters for a random script with a mandatory parameter?
Just to be clear here, I'm obviously not arguing to keep the current behavior, I'm just saying that if we fix the current behavior we need to provide an alternative for the people that actually wants to hide common parameters. |
Sometimes one writes advanced functions for simple users. I agree with @MartinGC94 that there's value in separating |
The Working Group has reviewed this -- we will investigate the original decision. The general feeling is that a parameter attribute should not affect other parameters or the common parameters. However, we would like to investigate the original reasoning behind disabling common parameters before making any changes - as it is very clear it was the desired behavior at the time. |
@theJasonHelmick Any update from the working group? |
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically. Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original. |
Summary of the new feature / enhancement
The DontShow attribute parameter that the Parameter attribute has allows a function/script author to hide parameters like this:
This has the side effect of also hiding the common parameters.
It seems to have been an intentional design choice, see this: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs#L768 but I think that should be changed because it makes it impractical to use
DontShow
to hide old deprecated parameters likeConvertTo-Csv
does with theNoTypeInformation
parameter because then the user won't see important common parameters likeErrorAction
.Proposed technical implementation details (optional)
Instead of automatically hiding common parameters when
DontShow
has been specified, add aHideCommonParameters
parameter to theCmdletBinding
attribute.The text was updated successfully, but these errors were encountered: