-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDownloadItems.ps1
More file actions
96 lines (86 loc) · 2.9 KB
/
Copy pathDownloadItems.ps1
File metadata and controls
96 lines (86 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
[CmdletBinding(DefaultParameterSetName = 'Include')]
param (
[Parameter(Mandatory = $false, ParameterSetName = 'Include')]
[Parameter(Mandatory = $false, ParameterSetName = 'Exclude')]
[Parameter(Mandatory = $false, ParameterSetName = 'ListItems')]
[Parameter(Mandatory = $false)]
[string]$ConfigPath,
[Parameter(Mandatory = $false, ParameterSetName = 'Include')]
[string[]]$IncludeNames,
[Parameter(Mandatory = $false, ParameterSetName = 'Exclude')]
[string[]]$ExcludeNames,
[Parameter(Mandatory = $false, ParameterSetName = 'ListItems')]
[switch]$ListItems
)
Set-StrictMode -Version 3.0
. "$PSScriptRoot\Modules\LoadModule.ps1" -ModuleNames @("Common", "Download") -Force | Out-Null
function ListItems {
param (
[Parameter(Mandatory = $true)]
[string]$ConfigPath
)
LmListObjects -ConfigPath $ConfigPath
}
function DownloadItems {
[CmdletBinding(DefaultParameterSetName = 'Include')]
param (
[Parameter(Mandatory = $true, ParameterSetName = 'Include')]
[Parameter(Mandatory = $true, ParameterSetName = 'Exclude')]
[Parameter(Mandatory = $false)]
[string]$ConfigPath,
[Parameter(Mandatory = $false, ParameterSetName = 'Include')]
[string[]]$IncludeNames,
[Parameter(Mandatory = $false, ParameterSetName = 'Exclude')]
[string[]]$ExcludeNames
)
#$IsVerbose = $PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue'
$objects = LmGetObjects -ConfigPath @($ConfigPath, "*")
switch ($PSCmdlet.ParameterSetName) {
'Include' {
if ($IncludeNames) {
$objects = $objects | Where-Object { $IncludeNames -icontains $_.Name }
}
break
}
'Exclude' {
if ($ExcludeNames) {
$objects = $objects | Where-Object { $ExcludeNames -inotcontains $_.Name }
}
break
}
}
foreach ($object in $objects) {
Write-Host "Project name $($object["Name"])" -ForegroundColor Blue
switch ($object["Type"]) {
"github" {
$params = $object."params"
DownloadGitHubItems @params
break
}
"direct" {
$name = $object["JobName"]
$JobName = "Download$name"
if (-not (TestFunction -Name $JobName)) {
break
}
$params = $object."params"
&"$JobName" @params
break
}
}
}
}
if ($PSBoundParameters.Count -gt 0) {
$params = $PSBoundParameters
switch ($PSCmdlet.ParameterSetName) {
{ ($_ -eq 'Include') -or ($_ -eq 'Exclude') } {
DownloadItems @params
break
}
'ListItems' {
$params.Remove("ListItems") | Out-Null
ListItems @params
break
}
}
}