forked from jdhitsolutions/ISEScriptingGeek
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrentProjects.ps1
More file actions
104 lines (86 loc) · 2.36 KB
/
CurrentProjects.ps1
File metadata and controls
104 lines (86 loc) · 2.36 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
97
98
99
100
101
102
103
104
#requires -version 4.0
<#
The list is a simple text file with the complete path to scripts you are working on.
#>
Function Add-CurrentProject {
<#
.Synopsis
Add the file to the current project list file
.Description
This command adds the current file path to the current project list. The list is simply a text file with full file names to a group of scripts that you might be working on. The ISEScriptingGeek module uses a built-in variable, $currentProjectList.
.Link
Edit-CurrentProject
Import-CurrentProject
#>
[cmdletbinding()]
Param(
[ValidateNotNullorEmpty()]
[string]$List = $currentProjectList
)
#add the current file path to the list if it isn't already there
If ((Get-Content -path $CurrentProjectList) -notcontains $psise.CurrentFile.FullPath) {
$psise.CurrentFile.FullPath | Out-File -FilePath $list -Encoding ascii -Append
}
else {
write-warning "$($psise.CurrentFile.FullPath) already in $list"
}
} #Add-CurrentProject
Function Edit-CurrentProject {
<#
.Synopsis
Edit the current project list file
.Description
Open the current project list in the PowerShell ISE to view or edit. You will need to manually remove items. The list is simply a text file with full file names to a group of scripts that you might be working on. The ISEScriptingGeek module uses a built-in variable, $currentProjectList.
.Link
Add-CurrentProject
Import-CurrentProject
#>
[cmdletbinding()]
Param(
[Parameter(Position=0,Mandatory)]
[ValidateScript({
if (Test-Path $_) {
$True
}
else {
Throw "Cannot validate path $_"
}
})]
[string]$List
)
psedit $list
} #Edit-CurrentProject
Function Import-CurrentProject {
<#
.Synopsis
Open files from the project list
.Description
Read the current project list and open each file in the ISE. The list is simply a text file with full file names to a group of scripts that you might be working on. The ISEScriptingGeek module uses a built-in variable, $currentProjectList.
.Link
Add-CurrentProject
Edit-CurrentProject
#>
[cmdletbinding()]
Param(
[Parameter(Position=0,Mandatory)]
[ValidateScript({
if (Test-Path $_) {
$True
}
else {
Throw "Cannot validate path $_"
}
})]
[string]$List
)
#get the list of file paths filtering out any blank lines
$items = Get-Content -Path $list | where {$_}
foreach ($item in $items) {
if (Test-Path $item) {
psedit $item
}
else {
write-warning "Can't find $item"
}
}
} #Import-CurrentProject