Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
6af1903
Fixed #58: Multi-line commands rendering wrong
tig Mar 11, 2020
a69373e
Fixed #58 - Newlines in commands render incorrectly
tig Mar 11, 2020
f155262
Added debug instructions to readme
tig Mar 11, 2020
440833e
Update src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs
tig Mar 11, 2020
dd2e765
simplified stripping of newline/linefeed
tig Mar 12, 2020
e66f614
Merge branch 'master' of tig:tig/GraphicalTools
tig Mar 14, 2020
ebcb92f
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Apr 12, 2020
dce01c8
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Apr 17, 2020
a2c0238
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Apr 19, 2020
2184386
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Apr 19, 2020
668c5c5
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Apr 20, 2020
9d2c85a
Merge branch 'master' of tig:tig/GraphicalTools
tig May 13, 2020
d15fb38
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Aug 24, 2020
49b9559
Merge branch 'master' of tig:tig/GraphicalTools into master
tig Sep 25, 2020
4175dc0
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Sep 27, 2020
53b1203
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Sep 27, 2020
941cef7
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Sep 29, 2020
06c8a1f
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Sep 29, 2020
474826e
made column spacing tigher
tig Sep 29, 2020
3112550
update to new Terminal.gui package; no code changes
tig Sep 29, 2020
67911d3
tweaked widths
tig Sep 29, 2020
86a72b5
removed excess padding on right
tig Sep 29, 2020
c95abc5
removed excess rows at bottom
tig Sep 29, 2020
869b578
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Sep 29, 2020
bed1c3d
Merge branch 'master' into tighter_columns
tig Sep 29, 2020
142ffe5
status bar wsa occluding window
tig Sep 29, 2020
65c3c5a
tweaks
tig Sep 30, 2020
fd934e1
fixed build scripts to only build ocgv
tig Oct 1, 2020
f58d592
Merge branch 'tighter_columns' into minui
tig Oct 1, 2020
8e89181
refactored to make logic more obvious
tig Oct 1, 2020
1137d7d
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Oct 3, 2020
e965afd
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Oct 3, 2020
967b503
merged
tig Oct 3, 2020
e530f37
removed orig files
tig Oct 3, 2020
4188094
Merge branch 'master' of tig:PowerShell/GraphicalTools into master
tig Oct 5, 2020
797de5e
Merge branch 'master' of tig:tig/GraphicalTools into master
tig Oct 11, 2020
be4bea2
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Oct 21, 2020
85d8578
Merge branch 'master' of tig:tig/GraphicalTools
tig Oct 21, 2020
a03fc9b
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Nov 18, 2020
da6e273
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Apr 1, 2021
cec80a4
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Jun 3, 2022
c172968
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Jul 30, 2022
25204bc
Upgrade to Terminal.Gui v1.7
tig Aug 3, 2022
5e0cdcc
Merge branch 'master' into minui
tig Aug 3, 2022
b474f84
removed border when minui is enabled
tig Aug 3, 2022
75ca4d1
re-implemented feature post merge screw up
tig Aug 3, 2022
fd6483e
tweaks
tig Aug 3, 2022
c06641e
improve VS code build and debug support
tig Aug 3, 2022
7c4bec7
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Aug 4, 2022
cf84116
Merge branch 'master' into minui
tig Aug 4, 2022
15ab348
Merge branch 'master' into select_all
tig Aug 4, 2022
6833168
On exit, ensure only visible marked items are output
tig Aug 4, 2022
9aa550b
Merge branch 'minui' into fix_121_filter_input
tig Aug 4, 2022
50289b2
Merge branch 'select_all' into fix_121_filter_input
tig Aug 4, 2022
e544340
Merge branch 'improve_ocgvbuild' into fix_121_filter_input
tig Aug 4, 2022
ac54e61
Fixes 87
tig Aug 4, 2022
241e3d9
merge
tig Aug 9, 2022
d21f8c5
Merge branch 'fix_121_filter_input' into merge_tig
tig Aug 9, 2022
04dde17
Merge branch 'improve_ocgvbuild' into minui
tig Aug 9, 2022
c254965
Merge branch 'minui' into merge_tig
tig Aug 9, 2022
d3c1a82
Merge branch 'master' of tig:tig/GraphicalTools
tig Aug 17, 2022
3efc919
Tweaked build to have a better test at end
tig Aug 17, 2022
59e1cf7
merge
tig Aug 17, 2022
ef2c384
removed merge artifacts
tig Aug 17, 2022
20ce945
exclude .orig files (merge artifacts)
tig Aug 17, 2022
e148c73
Merge branch 'merge_tig'
tig Aug 17, 2022
b709b2c
merge
tig Aug 24, 2022
f93eeae
Merge branch 'master' of tig:PowerShell/GraphicalTools
tig Aug 24, 2022
8503cc2
Updated HelpMessages; fixed old readme contents
tig Aug 25, 2022
a2b5058
Fixed typos in README.md
tig Aug 25, 2022
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
113 changes: 104 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The GraphicalTools repo contains the `Out-ConsoleGridView`
PowerShell Cmdlet providing console-based GUI experiences based on
[Terminal.Gui (gui.cs)](https://github.com/migueldeicaza/gui.cs).
[Terminal.Gui (gui.cs)](https://github.com/gui-cs/Terminal.Gui).

_Note:_ A module named `Microsoft.PowerShell.GraphicalTools` used to be built and published out of this repo, but per [#101](https://github.com/PowerShell/GraphicalTools/issues/101) it is deprecated and unmaintained until such time that it can be rewritten on top of [.NET MAUI](https://devblogs.microsoft.com/dotnet/introducing-net-multi-platform-app-ui/).

Expand All @@ -20,14 +20,109 @@ to view and filter objects graphically.

![screenshot of Out-ConsoleGridView](docs/Microsoft.PowerShell.ConsoleGuiTools/ocgv.gif)

### Examples
## Examples

Get a process ID:
```powershell
gps | ocgv -OutputMode Single
### Example 1: Output processes to a grid view

```PowerShell
PS C:\> Get-Process | Out-ConsoleGridView
```

This command gets the processes running on the local computer and sends them to a grid view window.

### Example 2: Use a variable to output processes to a grid view

```PowerShell
PS C:\> $P = Get-Process
PS C:\> $P | Out-ConsoleGridView -OutputMode Single
```

See the [F7 History](https://github.com/gui-cs/F7History) script to show the PowerShell command history when F7 is pressed.
This command also gets the processes running on the local computer and sends them to a grid view window.

The first command uses the Get-Process cmdlet to get the processes on the computer and then saves the process objects in the $P variable.

The second command uses a pipeline operator to send the $P variable to **Out-ConsoleGridView**.

By specifying `-OutputMode Single` the grid view window will be restricted to a single selection, ensuring no more than a single object is returned.

### Example 3: Display a formatted table in a grid view

```PowerShell
PS C:\> Get-Process | Select-Object -Property Name, WorkingSet, PeakWorkingSet | Sort-Object -Property WorkingSet -Descending | Out-ConsoleGridView
```

This command displays a formatted table in a grid view window.

It uses the Get-Process cmdlet to get the processes on the computer.

Then, it uses a pipeline operator (|) to send the process objects to the Select-Object cmdlet.
The command uses the **Property** parameter of **Select-Object** to select the Name, WorkingSet, and PeakWorkingSet properties to be displayed in the table.

Another pipeline operator sends the filtered objects to the Sort-Object cmdlet, which sorts them in descending order by the value of the **WorkingSet** property.

The final part of the command uses a pipeline operator (|) to send the formatted table to **Out-ConsoleGridView**.

You can now use the features of the grid view to search, sort, and filter the data.

### Example 4: Save output to a variable, and then output a grid view

```PowerShell
PS C:\> ($A = Get-ChildItem -Path $pshome -Recurse) | Out-ConsoleGridView
```

This command saves its output in a variable and sends it to **Out-ConsoleGridView**.

The command uses the Get-ChildItem cmdlet to get the files in the Windows PowerShell installation directory and its subdirectories.
The path to the installation directory is saved in the $pshome automatic variable.

The command uses the assignment operator (=) to save the output in the $A variable and the pipeline operator (|) to send the output to **Out-ConsoleGridView**.

The parentheses in the command establish the order of operations.
As a result, the output from the Get-ChildItem command is saved in the $A variable before it is sent to **Out-ConsoleGridView**.

### Example 5: Output processes for a specified computer to a grid view

```PowerShell
PS C:\> Get-Process -ComputerName "Server01" | ocgv -Title "Processes - Server01"
```

This command displays the processes that are running on the Server01 computer in a grid view window.

The command uses `ocgv`, which is the built-in alias for the **Out-ConsoleGridView** cmdlet, it uses the *Title* parameter to specify the window title.

### Example 6: Define a function to kill processes using a graphical chooser

```PowerShell
PS C:\> function killp { Get-Process | Out-ConsoleGridView -OutputMode Single -Filter $args[0] | Stop-Process -Id {$_.Id} }
PS C:\> killp note
```
This example shows defining a function named `killp` that shows a grid view of all running processes and allows the user to select one to kill it.

The example uses the `-Filter` paramter to filter for all proceses with a name that includes `note` (thus highlighting `Notepad` if it were running. Selecting an item in the grid view and pressing `ENTER` will kill that process.

### Example 7: Pass multiple items through Out-ConsoleGridView

```PowerShell
PS C:\> Get-Process | Out-ConsoleGridView -PassThru | Export-Csv -Path .\ProcessLog.csv
```

This command lets you select multiple processes from the **Out-ConsoleGridView** window.
The processes that you select are passed to the **Export-Csv** command and written to the ProcessLog.csv file.

The command uses the *PassThru* parameter of **Out-ConsoleGridView**, which lets you send multiple items down the pipeline.
The *PassThru* parameter is equivalent to using the Multiple value of the *OutputMode* parameter.

### Example 8: Use F7 as "Show Command History"

Add [gui-cs/F7History](https://github.com/gui-cs/F7History) to your Powershell profile.

Press `F7` to see the history for the current PowerShell instance

Press `Shift-F7` to see the history for all PowerShell instances.

Whatever you select within `Out-ConsoleGridView` will be inserted on your command line.

Whatever was typed on the command line prior to hitting `F7` or `Shift-F7` will be used as a filter.

## Development

Expand Down Expand Up @@ -97,14 +192,14 @@ you would like to contribute code, documentation, tests, or bug reports,
please read the [development section above](https://github.com/PowerShell/GraphicalTools#development)
to learn more.

## (Deprecated) Microsoft.PowerShell.GraphicalTools Architecture
## Microsoft.PowerShell.ConsoleGuiTools Architecture

`GraphicalTools` consists of 2 .NET Projects:
`ConsoleGuiTools` consists of 2 .NET Projects:

- ConsoleGuiTools - Cmdlet implementation for Out-ConsoleGridView
- OutGridView.Models - Contains data contracts between the GUI & Cmdlet

_Note:_ Previously, GraphicalTools also included the Avalonia-based `Out-GridView` which was implemented in `.\Microsoft.PowerShell.GraphicalTools` and `.\OutGridView.Gui`. These components have been deprecated (see note above).
_Note:_ Previously, this repo included `Microsoft.PowerShell.GraphicalTools` which included the Avalonia-based `Out-GridView` (implemented in `.\Microsoft.PowerShell.GraphicalTools` and `.\OutGridView.Gui`). These components have been deprecated (see note above).

## Maintainers

Expand Down
25 changes: 19 additions & 6 deletions docs/Microsoft.PowerShell.ConsoleGuiTools/Out-ConsoleGridView.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ external help file: ConsoleGuiToolsModule.dll-Help.xml
keywords: powershell,cmdlet
locale: en-us
Module Name: Microsoft.PowerShell.ConsoleGuiTools
ms.date: 08/09/2019
ms.date: 08/24/2022
schema: 2.0.0
title: Out-ConsoleGridView
---
Expand All @@ -18,7 +18,7 @@ Sends output to an interactive table in the same console window.

```PowerShell
Out-ConsoleGridView [-InputObject <psobject>] [-Title <string>] [-OutputMode {None | Single |
Multiple}] [-Filter <string>] [<CommonParameters>]
Multiple}] [-Filter <string>] [-MinUi] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -27,7 +27,7 @@ The **Out-ConsoleGridView** cmdlet sends the output from a command to a grid vie

You can use the following features of the table to examine your data:

- Quick Filter. Use the Filter box at the top of the window to search the text in the table. You can search for text in a particular column, search for literals, and search for multiple words. You can use the `-Filter` command to pre-populate the Filter box.
- Quick Filter. Use the Filter box at the top of the window to search the text in the table. You can search for text in a particular column, search for literals, and search for multiple words. You can use the `-Filter` command to pre-populate the Filter box. The filter uses regular expressions.

For instructions for using these features, type `Get-Help Out-ConsoleGridView -Full` and see How to Use the Grid View Window Features in the Notes section.

Expand Down Expand Up @@ -175,7 +175,7 @@ Accept wildcard characters: False

### -OutputMode
Specifies the items that the interactive window sends down the pipeline as input to other commands.
By default, this cmdlet does not generate any output.
By default, this cmdlet generates zero, one, or many items.

To send items from the interactive window down the pipeline, click to select the items (either the the mouse in terminals that support mouse or the `SPACE` key) and then press `ENTER`. `ESC` cancels.

Expand Down Expand Up @@ -215,6 +215,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -MinUi
If specified no window frame, filter box, or status bar will be displayed in the **Out-ConsoleGridView** window.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Expand All @@ -238,8 +253,6 @@ By default `Out-ConsoleGridView` returns objects representing the selected rows

## RELATED LINKS

[Out-GridView](Out-GridView.md)

[Out-File](Out-File.md)

[Out-Printer](Out-Printer.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@ public class OutConsoleGridViewCmdletCommand : PSCmdlet, IDisposable
/// <summary>
/// This parameter specifies the current pipeline object.
/// </summary>
[Parameter(ValueFromPipeline = true)]
[Parameter(ValueFromPipeline = true, HelpMessage = "Specifies the input pipeline object")]
public PSObject InputObject { get; set; } = AutomationNull.Value;

/// <summary>
/// Gets/sets the title of the Out-GridView window.
/// </summary>
[Parameter]
[Parameter(HelpMessage = "Specifies the text that appears in the title bar of the Out-ConsoleGridView window. y default, the title bar displays the command that invokes Out-ConsoleGridView.")]
[ValidateNotNullOrEmpty]
public string Title { get; set; }

/// <summary>
/// Get or sets a value indicating whether the selected items should be written to the pipeline
/// and if it should be possible to select multiple or single list items.
/// </summary>
[Parameter()]
[Parameter(HelpMessage = "Determines whether a single item (Single), multiple items (Multiple; default), or no items (None) will be written to the pipeline. Also determines selection behavior in the GUI.")]
public OutputModeOption OutputMode { set; get; } = OutputModeOption.Multiple;

/// <summary>
/// gets or sets the initial value for the filter in the GUI
/// </summary>
[Parameter()]
[Parameter(HelpMessage = "Pre-populates the Filter edit box, allowing filtering to be specified on the command line. The filter uses regular expressions." )]
public string Filter { set; get; }

/// <summary>
/// gets or sets the whether "minimum UI" mode will be enabled
/// </summary>
[Parameter()]
[Parameter(HelpMessage = "If specified no window frame, filter box, or status bar will be displayed in the GUI.")]
public SwitchParameter MinUI { set; get; }

#endregion Input Parameters
Expand Down