Skip to content

Commit 191bcc6

Browse files
committed
Add documentation for Out-CurrentFile
1 parent 20670da commit 191bcc6

File tree

3 files changed

+78
-7
lines changed

3 files changed

+78
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
function Out-CurrentFile {
2+
<#
3+
.EXTERNALHELP ..\PowerShellEditorServices.Commands-help.xml
4+
#>
5+
[CmdletBinding()]
26
param(
3-
[Parameter(ValueFromPipeline)]
4-
$data
7+
[Parameter(ValueFromPipeline, Mandatory=$true)]
8+
$InputObject
59
)
610

7-
Begin { $d = @() }
8-
Process { $d += $data }
11+
Begin { $objectsToWrite = @() }
12+
Process { $objectsToWrite += $InputObject }
913
End {
10-
$target = "@`"`r`n{0}`r`n`"@" -f ($d|out-string).Trim()
11-
$pseditor.GetEditorContext().currentfile.inserttext($target)
14+
$outputString = "@`"`r`n{0}`r`n`"@" -f ($objectsToWrite|out-string).Trim()
15+
$psEditor.GetEditorContext().CurrentFile.InsertText($outputString)
1216
}
13-
}
17+
}

module/docs/Out-CurrentFile.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
external help file: PowerShellEditorServices.Commands-help.xml
3+
online version: https://github.com/PowerShell/PowerShellEditorServices/tree/master/module/docs/Out-CurrentFile.md
4+
schema: 2.0.0
5+
---
6+
7+
# Out-CurrentFile
8+
9+
## SYNOPSIS
10+
11+
Sends the output through Out-String to the current open editor file.
12+
13+
## SYNTAX
14+
15+
```powershell
16+
Out-CurrentFile [-InputObject] <Object>
17+
```
18+
19+
## DESCRIPTION
20+
21+
The Out-CurrentFile cmdlet sends output through Out-String to the current open
22+
editor file.
23+
24+
## EXAMPLES
25+
26+
### Example 1
27+
28+
```powershell
29+
Get-Process | Out-CurrentFile
30+
```
31+
32+
Runs the `Get-Process` command and formats its output into the current
33+
editor file.
34+
35+
## PARAMETERS
36+
37+
### -InputObject
38+
39+
The input object to format, either as a parameter or from the pipeline.
40+
41+
```yaml
42+
Type: Object
43+
Parameter Sets: (All)
44+
Aliases:
45+
46+
Required: True
47+
Position: 0
48+
Default value: None
49+
Accept pipeline input: True (ByValue)
50+
Accept wildcard characters: False
51+
```
52+
53+
## INPUTS
54+
55+
### System.Object
56+
57+
## OUTPUTS
58+
59+
### System.Object
60+
61+
## NOTES
62+
63+
## RELATED LINKS

src/PowerShellEditorServices/Extensions/IEditorOperations.cs

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public interface IEditorOperations
3333
/// <returns>The resolved file path.</returns>
3434
string GetWorkspaceRelativePath(string filePath);
3535

36+
/// <summary>
37+
/// Causes a new untitled file to be created in the editor.
38+
/// </summary>
39+
/// <returns>A task that can be awaited for completion.</returns>
3640
Task NewFile();
3741

3842
/// <summary>

0 commit comments

Comments
 (0)