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

Removing Dynamic parameters #275

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
33fe74a
Add parameter classes
Jan 20, 2020
95860f6
import classes via PSD1, add exportFunctions list
Jan 20, 2020
a265bc7
Replace dynamic parameters with clasess
Jan 20, 2020
a42840a
Move _Supports* functionality into calling fn
Jan 21, 2020
da9245e
remove _isonwindows
Jan 21, 2020
2beaa35
remove _applyTypes
Jan 21, 2020
978e0cc
fix break of Add-VSteamWorkItem, improve build
Jan 21, 2020
1fd09ed
Merge remote-tracking branch 'upstream/master'
jhoneill Feb 27, 2020
c27dc5f
Use Invoke-VSTeamRequest externally and make _callApi Private again
jhoneill Feb 28, 2020
688bdf4
Auto-update of md help with 6.4.4 changes
Feb 28, 2020
e2bb372
Allow $env:testing to bypass validation checks
Feb 28, 2020
3467ddd
fix issue Getting build artifacts with no properties field
Feb 28, 2020
427114f
Fix regressions and modify mocking in tests to work with new classes
jhoneill Mar 1, 2020
d1bc72f
ensure validator doesn't break tests fix a couple more regressions & …
jhoneill Mar 1, 2020
99871e2
Merge remote-tracking branch 'upstream/master'
jhoneill Mar 1, 2020
7af8dab
Merge remote-tracking branch 'upstream/master'
jhoneill Mar 1, 2020
2fab630
Tidy class loading - Merge classes to PSM1 file.
Mar 17, 2020
51d9b49
Merge remote-tracking branch 'upstream/master'
jhoneill Mar 17, 2020
9d53c00
fix ProcessCompleter
Mar 17, 2020
e990b83
fix ProcessCompleter
Mar 17, 2020
80fcb5f
Merge branch 'master' of https://github.com/jhoneill/vsteam
jhoneill Mar 17, 2020
2608b10
Fixed tests to not mix source & built files.
Mar 18, 2020
fed84c4
Re-introduced a mockable to help one test (CI has 3 param not founds …
jhoneill Mar 19, 2020
abdb3a1
Fix build when file encodings are mixed
jhoneill Mar 31, 2020
2dea841
Merge remote-tracking branch 'upstream/master'
jhoneill Apr 7, 2020
615f08e
Merge remote-tracking branch 'upstream/master'
jhoneill Apr 28, 2020
bc18fa0
Meged update up to #283 from Upstream
jhoneill Apr 28, 2020
8a2ee54
Remove strict mode see DarqueWarrior/vsteam # 296
Apr 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .editorconfig

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Source/Classes/vsteam.classes.ps1
/dist
test-results.xml
coverage.xml
.editorconfig
.vscode/settings.json
.DS_Store
._.DS_Store
**/.DS_Store
Expand Down
19 changes: 5 additions & 14 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,9 @@
"vssgp",
"vssps"
],
"workbench.colorCustomizations": {
"activityBar.background": "#007699",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#ff80e2",
"activityBarBadge.foreground": "#15202b",
"titleBar.activeBackground": "#004f66",
"titleBar.inactiveBackground": "#004f6699",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveForeground": "#e7e7e799",
"statusBar.background": "#004f66",
"statusBarItem.hoverBackground": "#007699",
"statusBar.foreground": "#e7e7e7"
}
"terminal.integrated.commandsToSkipShell": [
"PowerShell.RunSelection",
"workbench.action.files.save",
"workbench.action.files.newUntitled"
]
}
26 changes: 17 additions & 9 deletions Build-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,22 @@ if ($buildHelp.IsPresent) {
}

Write-Output 'Publishing about help files'
Copy-Item -Path ./Source/en-US -Destination "$output/" -Recurse -Force
Copy-Item -Path ./Source/VSTeam.psm1 -Destination "$output/VSTeam.psm1" -Force
Copy-Item -Path ./Source/en-US -Destination "$output/" -Recurse -Force
Copy-Item -Path ./Source/VSTeam.psd1 -Destination "$output/VSTeam.psd1" -Force

Write-Output 'Updating Functions To Export'

Get-Content -Path ./Source/VSTeam.psm1 | Out-File -Append -FilePath "$output/VSTeam.psm1" -Encoding ascii
<#Write-Output 'Updating Functions To Export'
$newValue = ((Get-ChildItem -Path "./Source/Public" -Filter '*.ps1').BaseName |
ForEach-Object -Process { Write-Output "'$_'" }) -join ','
#>

(Get-Content "./Source/VSTeam.psd1") -Replace ("FunctionsToExport.+", "FunctionsToExport = ($newValue)") | Set-Content "$output/VSTeam.psd1"
$PSDsettings = Import-PowerShellDataFile -path "./Source/VSTeam.psd1"
Write-Output 'Updating Functions To Export'
$FunctionsToExport = @()
$FunctionsToExport += $PSDsettings.FunctionsToExport.where({$_ -like "_*"})
$FunctionsToExport += (Get-ChildItem -Path "./Source/Public" -Filter '*.ps1').BaseName
Update-ModuleManifest -Path "$output/VSTeam.psd1" -FunctionsToExport $FunctionsToExport

Write-Output "Publish complete to $output"

Expand All @@ -100,19 +108,19 @@ if ($ipmo.IsPresent -or $runTests.IsPresent) {
if ((Get-Module VSTeam)) {
Remove-Module VSTeam
}

Import-Module "$output/VSTeam.psd1" -Force
$env:testing = $true
Import-Module "$output/VSTeam.psd1" -Global -Force
Set-VSTeamAlias
}

# run the unit tests with Pester
if ($runTests.IsPresent) {
if ($null -eq $(Get-Module -Name Pester)) {
if ($null -eq $(Get-Module -ListAvailable Pester)) {
Install-Module -Name Pester -Repository PSGallery -Force -Scope CurrentUser -AllowClobber -SkipPublisherCheck
}

$pesterArgs = @{
Script = '.\unit'
Script = '.\unit'
OutputFile = 'test-results.xml'
OutputFormat = 'NUnitXml'
Show = 'Fails'
Expand All @@ -136,7 +144,7 @@ if ($runTests.IsPresent) {
$pesterArgs.PassThru = $true
}

Invoke-Pester @pesterArgs
Invoke-Pester @pesterArgs
}

# Run this last so the results can be seen even if tests were also run
Expand Down
142 changes: 142 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,146 @@
# Changelog
- Removed dependency on trackyon.utils (incl. adding Show-Browser function)
- Changed load sequence for classes to allow them to be accessible when parameters evaluated
- Replaced dynamic parameters with argument completers / validators
- Changing the load sequence breaks some Pester because what is making the call is out of scope, so moved the mocked item upstream so it is called by something in scope.



## 6.4.4

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/257) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Fix bug in Get-VSTeamBuildArtifact with additional "properties" property

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/245) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add Get-VSTeamGitStats to retrieve statistics about branches

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/244) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add support for licensingSource and msdnLicenseType to Add-VSTeamUserEntitlement / Update-VSTeamUserEntitlement

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/243) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add additional filtering capabilities to Get-VSTeamPullRequest

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/242) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added "-and" operator to the Membership tests

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/241) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added Update-VSTeamPullRequest to manipulate some basics about Pull Requests
- Added Add-VSTeamPullRequest to create Pull Requests

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/240) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add option to add additional headers (-AdditionalHeaders) to the request generated by the `Invoke-VSTeamRequest` call

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/239) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added ;charset=utf-8 to POST/PUT JSON requests

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/238) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added Get-VSTeamGitCommit to retrieve commits

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/237) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add -Filter, -FilterContains, -Top and -ContinuationToken to Get-VSTeamGitRefs

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/232) from [Mark Wragg](https://github.com/markwragg) which included the following:

- Bug fix in Get-VSTeamBuildArtifact where an error is returned because the API returns an extra record along with the list of artifacts that is called 'build.sourcelabel' and contains a URL but no "properties" object.

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/231) from [Dave Neeley](https://github.com/daveneeley) which included the following:

- Removed a trailing slash from resource URIs generated by `_BuildRequestURI` when the ID parameter is not included in the function call.

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/225) from [Cadacious](https://github.com/Cadacious) which included the following:

- Added Get/Set-VSTeamPermissionInheritance

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/224) from [Cadacious](https://github.com/Cadacious) which included the following:

- Adds Remove-VSTeamAccessControlEntry

## 6.4.3

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/229) from [Asif Mithawala](https://github.com/asifma) which included the following:

Added additional property checks in VSTeamJobRequest

## 6.4.5

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/273) from [Lukas Wöhrl](https://github.com/woehrl01) which included the following:

Adds a new function Update-VSTeamAgent which allows to update the agent version

## 6.4.4

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/257) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Fix bug in Get-VSTeamBuildArtifact with additional "properties" property

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/245) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add Get-VSTeamGitStats to retrieve statistics about branches

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/244) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add support for licensingSource and msdnLicenseType to Add-VSTeamUserEntitlement / Update-VSTeamUserEntitlement

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/243) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add additional filtering capabilities to Get-VSTeamPullRequest

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/242) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added "-and" operator to the Membership tests

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/241) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added Update-VSTeamPullRequest to manipulate some basics about Pull Requests
- Added Add-VSTeamPullRequest to create Pull Requests

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/240) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add option to add additional headers (-AdditionalHeaders) to the request generated by the `Invoke-VSTeamRequest` call

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/239) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added ;charset=utf-8 to POST/PUT JSON requests

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/238) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Added Get-VSTeamGitCommit to retrieve commits

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/237) from [Michel Zehnder](https://github.com/MichelZ) which included the following:

- Add -Filter, -FilterContains, -Top and -ContinuationToken to Get-VSTeamGitRefs

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/232) from [Mark Wragg](https://github.com/markwragg) which included the following:

- Bug fix in Get-VSTeamBuildArtifact where an error is returned because the API returns an extra record along with the list of artifacts that is called 'build.sourcelabel' and contains a URL but no "properties" object.

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/231) from [Dave Neeley](https://github.com/daveneeley) which included the following:

- Removed a trailing slash from resource URIs generated by `_BuildRequestURI` when the ID parameter is not included in the function call.

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/225) from [Cadacious](https://github.com/Cadacious) which included the following:

- Added Get/Set-VSTeamPermissionInheritance

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/224) from [Cadacious](https://github.com/Cadacious) which included the following:

- Adds Remove-VSTeamAccessControlEntry

## 6.4.3

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/229) from [Asif Mithawala](https://github.com/asifma) which included the following:

Added additional property checks in VSTeamJobRequest

## 6.4.7

Expand Down
2 changes: 1 addition & 1 deletion Merge-File.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PS C:\> Merge-File -InputFile .\Source\Classes\classes.json
Merge-Type $files | Add-Content $output
}
'functions' {
Merge-Function $files | Add-Content $output
Merge-Function $files | Add-Content $output -Encoding Ascii
}
Default {
Merge-Class $files | Add-Content $output
Expand Down
16 changes: 16 additions & 0 deletions Source/Classes/BuildCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class BuildCompleter : System.Management.Automation.IArgumentCompleter {
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete,
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters
) {
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
if ($Global:PSDefaultParameterValues["*:projectName"]){
foreach ($b in (Get-VSTeamBuild -ProjectName $Global:PSDefaultParameterValues["*:projectName"]).name ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to be careful with code like this. If Get-VSTeamBuild returns an empty Array this will post the following error.

The property 'name' cannot be found on this object. Verify that the property exists.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the code to this.

foreach ($b in (Get-VSTeamBuild -ProjectName $(_getDefaultProject))) {
            if ($b.name -like "*$WordToComplete*") {
               $results.Add([CompletionResult]::new($b.name))
            }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny that the code works because builds don't have a name. They have a buildNumber. But that code was working... I changed to buildNumber and it is still working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be to do with strictmode . When it's off ($null).name is fine, , when it is on it gives that error. I noticed the tests turn strictmode on, and I have a tendency to write code which relies on it being off. If you need/want to change that anywhere feel free to do so :-)

There are a couple of cases where dynamic parameters may still be the most sensible way to do it - that's usually where the value of parameter A determines if parameter B is visible or not. And I may have left some in that are only used once.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Good to know.

if ($b -like "*$WordToComplete*") {
$results.Add([System.Management.Automation.CompletionResult]::new($b))
}
}
}
return $results
}
}
16 changes: 16 additions & 0 deletions Source/Classes/BuildDefinitionCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class BuildDefinitionCompleter : System.Management.Automation.IArgumentCompleter {
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete,
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters
) {
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
if ($Global:PSDefaultParameterValues["*:projectName"]){
foreach ($b in (Get-VSTeamBuildDefinition -ProjectName $Global:PSDefaultParameterValues["*:projectName"]).name ) {
if ($b -like "*$WordToComplete*") {
$results.Add([System.Management.Automation.CompletionResult]::new($b))
}
}
}
return $results
}
}
19 changes: 19 additions & 0 deletions Source/Classes/ProcessCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class ProcessCompleter : System.Management.Automation.IArgumentCompleter {
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete,
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters
) {
$minutesNow = (Get-Date).TimeOfDay.TotalMinutes
if ( ([VSTeamProcessCache]::timestamp + 100 -lt $minutesNow) -and ( [VSTeamVersions]::Account) ) {
[VSTeamProcessCache]::processes = (Invoke-VSTeamRequest -url ('{0}/_apis/process/processes?api-version={1}&stateFilter=All&$top=9999' -f [VSTeamVersions]::Account, [VSTeamVersions]::Core )).value.name
[VSTeamProcessCache]::timestamp = $minutesNow
}
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
foreach ($p in [VSTeamProcessCache]::processes ) {
if ($p -like "*$WordToComplete*") {
$results.Add([System.Management.Automation.CompletionResult]::new($p))
}
}
return $results
}
}
23 changes: 23 additions & 0 deletions Source/Classes/ProjectCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class ProjectCompleter : System.Management.Automation.IArgumentCompleter {
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete,
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters
) {
if ( [VSTeamVersions]::Account -and
([VSTeamProjectCache]::timestamp -lt 0 -or
[VSTeamProjectCache]::timestamp -lt [datetime]::Now.TimeOfDay.TotalMinutes - 5) ) {
[VSTeamProjectCache]::projects = (Invoke-VSTeamRequest -url ('{0}/_apis/projects?api-version={1}&stateFilter=All&$top=9999' -f [VSTeamVersions]::Account, [VSTeamVersions]::Core )).value.name
[VSTeamProjectCache]::timestamp = (Get-Date).TimeOfDay.TotalMinutes
}
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
foreach ($p in [VSTeamProjectCache]::projects ) {
if ($p -like "*$WordToComplete*" -and $p -match "\s") {
$results.Add([System.Management.Automation.CompletionResult]::new("'$p'"))
}
elseif ($p -like "*$WordToComplete*"){
$results.Add([System.Management.Automation.CompletionResult]::new($p))
}
}
return $results
}
}
28 changes: 28 additions & 0 deletions Source/Classes/QueryCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class QueryCompleter : System.Management.Automation.IArgumentCompleter {
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete,
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters
) {
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
$projName = $FakeBoundParameters['ProjectName']
if (-not $projName -and $Global:PSDefaultParameterValues["*:projectName"]) {
$projName = $Global:PSDefaultParameterValues["*:projectName"]
}
if (-not $projName) {return $results}
if ([VSTeamQueryCache]::timestamp -lt 0 -or
[VSTeamQueryCache]::timestamp -lt [datetime]::Now.TimeOfDay.TotalMinutes -5) {
[VSTeamQueryCache]::queries = (Invoke-VSTeamRequest -ProjectName $projName -Area wit -Resource queries -version ([vsteamversions]::core) -QueryString @{'$depth'=1}
).value.children | Select-Object Name,ID | Sort-Object Name
[VSTeamQueryCache]::timestamp = (Get-Date).TimeOfDay.TotalMinutes
}
foreach ($q in [VSTeamQueryCache]::queries ) {
if ($q.name -like "*$WordToComplete*" -and $q.name -match "[\s'\(\[#;@]") {
$results.Add([System.Management.Automation.CompletionResult]::new(('"{0}"' -f $q.name)))
}
elseif ($q.name -like "*$WordToComplete*"){
$results.Add([System.Management.Automation.CompletionResult]::new($q.name))
}
}
return $results
}
}
9 changes: 9 additions & 0 deletions Source/Classes/QueryTransformToIDAttribute.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class QueryTransformToIDAttribute : System.Management.Automation.ArgumentTransformationAttribute {
[object] Transform([System.Management.Automation.EngineIntrinsics]$EngineIntrinsics, [object] $InputData) {
if ($InputData -notmatch "[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}" -and
[VSTeamQueryCache]::queries.where({$_.name -eq $InputData}).count) {
$InputData = [VSTeamQueryCache]::queries.where({$_.name -eq $InputData}).id
}
return ($InputData)
}
}
16 changes: 16 additions & 0 deletions Source/Classes/ReleaseDefinitionCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class ReleaseDefinitionCompleter : System.Management.Automation.IArgumentCompleter {
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete,
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters
) {
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
if ($Global:PSDefaultParameterValues["*:projectName"]){
foreach ($r in (Get-VSTeamReleaseDefinition -ProjectName $Global:PSDefaultParameterValues["*:projectName"]).name ) {
if ($r -like "*$WordToComplete*") {
$results.Add([System.Management.Automation.CompletionResult]::new($r))
}
}
}
return $results
}
}
Loading