Skip to content

Commit 2a957d9

Browse files
v1.4.0
1 parent b455432 commit 2a957d9

24 files changed

+506
-424
lines changed

ChangeLog.md

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,98 @@
11
# ChangeLog for PSFunctionInfo
22

3+
## 1.4.0
4+
5+
### Changed
6+
7+
- Code cleanup
8+
- Modified `Get-PSFunctionInfo` to sort functions by name.
9+
- Help updates
10+
- Updated `README`
11+
12+
### Fixed
13+
14+
- Added a warning to `Set-PSFunctionInfoDefaults` if the command is run without specifying any parameters.
15+
-
316
## 1.3.0
417

5-
+ Updated missing online help links.
6-
+ Help documentation updates.
7-
+ Updated `README.md`.
18+
- Updated missing online help links.
19+
- Help documentation updates.
20+
- Updated `README.md`.
821

922
## 1.2.0
1023

11-
+ Added custom error messages to `ValidateScript()` parameter attributes.
12-
+ Added a `NoSource` parameter to `New-PSFunctionInfo` to not include the source path.
13-
+ Added `Set-PSFunctionInfo` and its alias `spfi`.
14-
+ Added `Remove-PSFunctionInfo` and its alias `rpfi`.
15-
+ Help updates.
16-
+ Updated `README.md`.
24+
- Added custom error messages to `ValidateScript()` parameter attributes.
25+
- Added a `NoSource` parameter to `New-PSFunctionInfo` to not include the source path.
26+
- Added `Set-PSFunctionInfo` and its alias `spfi`.
27+
- Added `Remove-PSFunctionInfo` and its alias `rpfi`.
28+
- Help updates.
29+
- Updated `README.md`.
1730

1831
## 1.1.0
1932

20-
+ Fixed DefaultDisplayPropertySet in types.ps1xml file.
21-
+ Added online help links.
22-
+ Updated `README.md`.
33+
- Fixed DefaultDisplayPropertySet in types.ps1xml file.
34+
- Added online help links.
35+
- Updated `README.md`.
2336

2437
## 1.0.0
2538

26-
+ Restructured module layout.
27-
+ Added a property set called `TagInfo`.
28-
+ Added command `Edit-PSFunctionInfo` with an alias of `efpi`. ([Issue #7](https://github.com/jdhitsolutions/PSFunctionInfo/issues/7))
29-
+ Added better error handling to `Get-PSFunctionInfo` where function can't be found.
30-
+ Help updates.
31-
+ First official release to the PowerShell Gallery.
32-
+ Updated `README.md`.
39+
- Restructured module layout.
40+
- Added a property set called `TagInfo`.
41+
- Added command `Edit-PSFunctionInfo` with an alias of `efpi`. ([Issue #7](https://github.com/jdhitsolutions/PSFunctionInfo/issues/7))
42+
- Added better error handling to `Get-PSFunctionInfo` where function can't be found.
43+
- Help updates.
44+
- First official release to the PowerShell Gallery.
45+
- Updated `README.md`.
3346

3447
## 0.6.0-preview
3548

36-
+ Fixed the `-Name` parameter argument completer in `Get-PSFunctionInfo`. The function parameter changed from `Name` to `FunctionName` which is why it broke. ([Issue #6](https://github.com/jdhitsolutions/PSFunctionInfo/issues/6))
37-
+ Created private function `backup_file`.
38-
+ Added a `-Backup` parameter to `New-PSFunctionInfo`. ([Issue #1](https://github.com/jdhitsolutions/PSFunctionInfo/issues/1))
39-
+ Help updates
40-
+ Updated `README.md`.
49+
- Fixed the `-Name` parameter argument completer in `Get-PSFunctionInfo`. The function parameter changed from `Name` to `FunctionName` which is why it broke. ([Issue #6](https://github.com/jdhitsolutions/PSFunctionInfo/issues/6))
50+
- Created private function `backup_file`.
51+
- Added a `-Backup` parameter to `New-PSFunctionInfo`. ([Issue #1](https://github.com/jdhitsolutions/PSFunctionInfo/issues/1))
52+
- Help updates
53+
- Updated `README.md`.
4154

4255
## 0.5.0-preview
4356

44-
+ Added an autocompleter for the `-Tag` parameter in `Get-PSFunctionInfo`. ([Issue #4](https://github.com/jdhitsolutions/PSFunctionInfo/issues/4))
45-
+ Added a private function, `new_psfunctioninfo`, to create a new PSFunctionInfo object from the metadata block.
46-
+ Changed `Name` parameter in `Get-PSFunctionInfo` to `FunctionName`. The parameter is positional, so it shouldn't make much difference. **This is a breaking change.**
47-
+ Modified `Get-PSFunctionInfo` to get metadata from files. ([Issue #3](https://github.com/jdhitsolutions/PSFunctionInfo/issues/3))
48-
+ Modified `PSFunctionInfo` class to not require Tags in the constructor.
49-
+ Added missing online help links.
50-
+ Added a table view called `tags` to `psfunctioninfor.format.ps1xml`.
51-
+ Modified `psfunctioninfor.format.ps1xml` to reduce the `Alias` column to 15.
52-
+ Added integration into the PowerShell ISE.
53-
+ Added integration into VS Code. ([Issue #2](https://github.com/jdhitsolutions/PSFunctionInfo/issues/2))
54-
+ Updated help documentation.
55-
+ Updated `README.md`.
57+
- Added an autocompleter for the `-Tag` parameter in `Get-PSFunctionInfo`. ([Issue #4](https://github.com/jdhitsolutions/PSFunctionInfo/issues/4))
58+
- Added a private function, `new_psfunctioninfo`, to create a new PSFunctionInfo object from the metadata block.
59+
- Changed `Name` parameter in `Get-PSFunctionInfo` to `FunctionName`. The parameter is positional, so it shouldn't make much difference. **This is a breaking change.**
60+
- Modified `Get-PSFunctionInfo` to get metadata from files. ([Issue #3](https://github.com/jdhitsolutions/PSFunctionInfo/issues/3))
61+
- Modified `PSFunctionInfo` class to not require Tags in the constructor.
62+
- Added missing online help links.
63+
- Added a table view called `tags` to `psfunctioninfor.format.ps1xml`.
64+
- Modified `psfunctioninfor.format.ps1xml` to reduce the `Alias` column to 15.
65+
- Added integration into the PowerShell ISE.
66+
- Added integration into VS Code. ([Issue #2](https://github.com/jdhitsolutions/PSFunctionInfo/issues/2))
67+
- Updated help documentation.
68+
- Updated `README.md`.
5669

5770
## 0.4.0-preview
5871

59-
+ Added `Set-PSFunctionInfoDefaults` and `Get-PSFunctionInfoDefaults` to store default values. The defaults are stored in a JSON file at `$home\psfunctioninfo-defaults.json`. If the file is found when the module is imported, it will be used to set $PSDefaultParameterValues for this module.
60-
+ Added `Update-PSFunctionInfoDefaults` which can be used to update defaults if they are changed after the module has been loaded.
61-
+ Added `about_PSFunctionInfo` help.
62-
+ Minor help updates.
63-
+ Updated `README.md`.
72+
- Added `Set-PSFunctionInfoDefaults` and `Get-PSFunctionInfoDefaults` to store default values. The defaults are stored in a JSON file at `$home\psfunctioninfo-defaults.json`. If the file is found when the module is imported, it will be used to set $PSDefaultParameterValues for this module.
73+
- Added `Update-PSFunctionInfoDefaults` which can be used to update defaults if they are changed after the module has been loaded.
74+
- Added `about_PSFunctionInfo` help.
75+
- Minor help updates.
76+
- Updated `README.md`.
6477

6578
## 0.3.0-preview
6679

67-
+ Added online help links.
68-
+ Published pre-release module to the PowerShell Gallery.
69-
+ Updated `README.md`.
80+
- Added online help links.
81+
- Published pre-release module to the PowerShell Gallery.
82+
- Updated `README.md`.
7083

7184
## 0.2.0
7285

73-
+ Modified `Source` view in `psfunctioninfo.format.ps1xml` to not limit the Description width.
74-
+ Updated `New-PSFunctionInfo` to better handle different function layouts.
75-
+ Added Verbose output to `Get-PSFunctionInfoTag`.
76-
+ Help updates.
77-
+ Added an argument completer for the `Name` parameter of `Get-PSFunctionInfo`.
78-
+ Added alias `gpfi` for `Get-PSFunctionInfo`.
79-
+ Added alias `npfi` for `New-PSFunctionInfo`.
80-
+ Updated module manifest.
81-
+ Updated `README.md`.
86+
- Modified `Source` view in `psfunctioninfo.format.ps1xml` to not limit the Description width.
87+
- Updated `New-PSFunctionInfo` to better handle different function layouts.
88+
- Added Verbose output to `Get-PSFunctionInfoTag`.
89+
- Help updates.
90+
- Added an argument completer for the `Name` parameter of `Get-PSFunctionInfo`.
91+
- Added alias `gpfi` for `Get-PSFunctionInfo`.
92+
- Added alias `npfi` for `New-PSFunctionInfo`.
93+
- Updated module manifest.
94+
- Updated `README.md`.
8295

8396
## 0.1.0
8497

85-
+ initial module files
98+
- initial module files

License.txt

0 Bytes
Binary file not shown.

PSFunctionInfo.psd1

0 Bytes
Binary file not shown.

PSFunctionInfo.psm1

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Get-ChildItem $PSScriptRoot\functions\*.ps1 | ForEach-Object {
32
. $_.FullName
43
}
@@ -7,37 +6,37 @@ Get-ChildItem $PSScriptRoot\functions\*.ps1 | ForEach-Object {
76
$defaults = Join-Path $home -ChildPath psfunctioninfo-defaults.json
87
if (Test-Path -path $defaults) {
98
$d = Get-Content -Path $defaults | ConvertFrom-JSON
10-
$d.psobject.properties | Foreach-Object {
9+
$d.PSObject.properties | Foreach-Object {
1110
$global:PSDefaultParameterValues["New-PSFunctionInfo:$($_.name)"] = $_.value
1211
}
1312
}
1413

1514
#Add VSCode Shortcuts
1615
if ($host.name -eq 'Visual Studio Code Host') {
17-
$global:PSDefaultParameterValues["New-PSFunctionInfo:Path"] = {$pseditor.GetEditorContext().CurrentFile.Path}
16+
$global:PSDefaultParameterValues["New-PSFunctionInfo:Path"] = {$PSEditor.GetEditorContext().CurrentFile.Path}
1817

1918
#create an argument completer for the Name parameter
2019
Register-ArgumentCompleter -CommandName New-PSFunctionInfo -ParameterName Name -ScriptBlock {
21-
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
22-
23-
#PowerShell code to populate $wordtoComplete
24-
$asttokens = $pseditor.GetEditorContext().CurrentFile.tokens
25-
$namelist = @()
26-
for ($i=0;$i -lt $asttokens.count;$i++) {
27-
if ($asttokens[$i].text -eq 'function') {
28-
$namelist+= $asttokens[$i+1].text
20+
param($commandName, $parameterName, $WordToComplete, $commandAst, $fakeBoundParameter)
21+
22+
#PowerShell code to populate $WordToComplete
23+
$ASTTokens = $PSEditor.GetEditorContext().CurrentFile.tokens
24+
$NameList = @()
25+
for ($i=0;$i -lt $ASTTokens.count;$i++) {
26+
if ($ASTTokens[$i].text -eq 'function') {
27+
$NameList+= $ASTTokens[$i+1].text
2928
}
30-
}
31-
$namelist | Where-Object {$_ -like "$WordtoComplete*"} |
29+
}
30+
$NameList | Where-Object {$_ -like "$WordToComplete*"} |
3231
ForEach-Object {
33-
# completion text,listitem text,result type,Tooltip
32+
# completion text,listItem text,result type,Tooltip
3433
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
3534
}
3635
}
3736
}
3837
elseif ($host.name -eq 'Windows PowerShell ISE Host') {
3938
#create shortcut for the ISE
40-
$global:PSDefaultParameterValues["New-PSFunctionInfo:Path"] = {$psise.CurrentFile.fullpath}
39+
$global:PSDefaultParameterValues["New-PSFunctionInfo:Path"] = {$PSIse.CurrentFile.FullPath}
4140

4241
#add a menu item
4342
$sb = {
@@ -110,25 +109,25 @@ elseif ($host.name -eq 'Windows PowerShell ISE Host') {
110109
[void]($form.ShowDialog())
111110
}
112111

113-
if ($psise.CurrentFile.IsSaved) {
114-
$Path = $psise.CurrentFile.FullPath
112+
if ($PSIse.CurrentFile.IsSaved) {
113+
$Path = $PSIse.CurrentFile.FullPath
115114

116-
New-Variable astTokens -Force
115+
New-Variable ASTTokens -Force
117116
New-Variable astErr -Force
118-
$AST = [System.Management.Automation.Language.Parser]::ParseFile($Path, [ref]$astTokens, [ref]$astErr)
117+
$AST = [System.Management.Automation.Language.Parser]::ParseFile($Path, [ref]$ASTTokens, [ref]$astErr)
119118

120119
$file = [System.Collections.Generic.list[string[]]]::new()
121120
Get-Content $path | ForEach-Object { $file.Add($_) }
122121

123122
$name = @()
124-
for ($i = 0; $i -lt $asttokens.count; $i++) {
125-
if ($asttokens[$i].text -eq 'function') {
126-
$name += $asttokens[$i + 1].text
123+
for ($i = 0; $i -lt $ASTTokens.count; $i++) {
124+
if ($ASTTokens[$i].text -eq 'function') {
125+
$name += $ASTTokens[$i + 1].text
127126
}
128127
} #for
129128
if ($name) {
130129
Remove-Variable -Name SelectedPickItem -ErrorAction SilentlyContinue
131-
picklist -name $name
130+
PickList -name $name
132131
#| Out-GridView -Title "Select a function" -OutputMode Single
133132

134133
if ($SelectedPickItem) {
@@ -137,9 +136,9 @@ elseif ($host.name -eq 'Windows PowerShell ISE Host') {
137136
$idx = $file.findIndex( { $args[0] -match "[Ff]unction(\s+)$SelectedPickItem" })
138137
$idx++
139138
#save and re-open the file
140-
[void]$psISE.CurrentPowerShellTab.files.Remove($psise.CurrentFile)
141-
[void]$psise.CurrentPowerShellTab.Files.Add($path)
142-
$r = $psise.CurrentPowerShellTab.Files.where( { $_.fullpath -eq $path })
139+
[void]$PSIse.CurrentPowerShellTab.files.Remove($PSIse.CurrentFile)
140+
[void]$PSIse.CurrentPowerShellTab.Files.Add($path)
141+
$r = $PSIse.CurrentPowerShellTab.Files.where( { $_.FullPath -eq $path })
143142
$r.Editor.Focus()
144143

145144
if ($idx -ge 0) {
@@ -158,26 +157,26 @@ elseif ($host.name -eq 'Windows PowerShell ISE Host') {
158157
}
159158
}
160159

161-
$psise.CurrentPowerShellTab.AddOnsMenu.Submenus.add("New-PSFunctionInfo", $sb, $Null)
160+
$PSIse.CurrentPowerShellTab.AddOnsMenu.Submenus.add("New-PSFunctionInfo", $sb, $Null)
162161
}
163162

164163
#create an argument completer
165164
Register-ArgumentCompleter -CommandName Get-PSFunctionInfo -ParameterName FunctionName -ScriptBlock {
166-
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
165+
param($commandName, $parameterName, $WordToComplete, $commandAst, $fakeBoundParameter)
167166

168-
Get-Childitem -path "Function:\$wordToComplete*" |
167+
Get-ChildItem -path "Function:\$WordToComplete*" |
169168
ForEach-Object {
170-
# completion text,listitem text,result type,Tooltip
169+
# completion text,listItem text,result type,Tooltip
171170
[System.Management.Automation.CompletionResult]::new($_.name, $_.name, 'ParameterValue', $_.name)
172171
}
173172
}
174173

175174
Register-ArgumentCompleter -CommandName Get-PSFunctionInfo -ParameterName Tag -ScriptBlock {
176-
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
175+
param($commandName, $parameterName, $WordToComplete, $commandAst, $fakeBoundParameter)
177176

178-
(Get-PSFunctionInfoTag).where({$_ -like "$wordToComplete*"}) |
177+
(Get-PSFunctionInfoTag).where({$_ -like "$WordToComplete*"}) |
179178
ForEach-Object {
180-
# completion text,listitem text,result type,Tooltip
179+
# completion text,listItem text,result type,Tooltip
181180
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
182181
}
183182
}

0 commit comments

Comments
 (0)