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

Consider reducing the scope of the default parameter "Project" from "*" to "*-VsTeam*" #297

Closed
jhoneill opened this issue Apr 30, 2020 · 4 comments

Comments

@jhoneill
Copy link
Contributor

jhoneill commented Apr 30, 2020

After a frustrating debugging session which turned out to be something with a ProjectName parameter being passed a default, I'm now of the opinion that the default should only apply to commands with -VsTeam nouns. Changing is a matter of a global search and replace of
$Global:PSDefaultParameterValues['*:projectName']
With
$Global:PSDefaultParameterValues['*-Vsteam*:projectName']
I have been doing this successfully on my development branch for a little while but haven't added it to the branch that is the subject of a PR because (a) there may be side effects I don't know about and (b) That PR is quite big enough already.

@DarqueWarrior
Copy link
Collaborator

Was the original default value being passed to cmdlets of other modules? I never even considered that! So sorry for the trouble.

@DarqueWarrior
Copy link
Collaborator

Searching for just '*:projectName' returns a lot more places. Let me see if all the alias still use the projectName if we add the -VSteam to it.

DarqueWarrior added a commit that referenced this issue May 1, 2020
@jhoneill
Copy link
Contributor Author

jhoneill commented May 1, 2020

EditI just checked, defaults do work for aliases . You can define a default for an alias, or for the canonical name, but you can't defined different ones for each. End edit

I was writing new functions which use _callApi and (a) they were getting passed the project name and I couldn't see why a parameter set without projectname never got selected and I was focusing on the parameter sets being the cause, so spent a long time looking in the wrong place for the problem (b) _callApi was being called with a project name when I wasn't passing it one.
Projectname could be used in other modules but isn't in that I can think of

I would prefer a script: scoped or global: scoped variable to be the parameter default, but that's a change which needs a lot more work.

@DarqueWarrior
Copy link
Collaborator

I see. I scoped it as you suggested but I fixed the other problem by adding the -NoProject flag to the _callAPI function. That flag has _callAPI ignore any default value stored for project. But now understanding this better I might remove the -NoProject flag now that the default is properly scoped to just external functions. I will do some testing. Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants