Skip to content

Commit

Permalink
aliases validateset out-display
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt authored and colombod committed Feb 22, 2020
1 parent 57b23be commit 6fefff4
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ namespace Microsoft.DotNet.Interactive.PowerShell.Commands
/// </summary>
[Cmdlet(VerbsCommon.Get, "HtmlContent")]
[OutputType("AspNetCore.Html.IHtmlContent")]
[Alias("ghc")]
public sealed class GetHtmlContentCommand : PSCmdlet
{
/// <summary>
/// The object from pipeline.
/// The Html string to convert into an HtmlContent object.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public string HtmlString { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@ namespace Microsoft.DotNet.Interactive.PowerShell.Commands
/// </summary>
[Cmdlet(VerbsCommon.New, "PlotlyChart")]
[OutputType("XPlot.Plotly.Chart")]
[Alias("npc")]
public sealed class NewPlotlyChartCommand : PSCmdlet
{
/// <summary>
/// The object from pipeline.
/// The traces to show in a chart.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public Trace[] Trace { get; set; }

/// <summary>
/// The title of the chart.
/// </summary>
[Parameter(Position = 1)]
public string Title { get; set; } = "Untitled Chart";

private List<Trace> _traces;

/// <summary>
/// BeginProcessing override.
/// </summary>
protected override void BeginProcessing()
{
_traces = new List<Trace>();
Expand All @@ -41,6 +48,9 @@ protected override void ProcessRecord()
_traces.AddRange(Trace);
}

/// <summary>
/// EndProcessing override.
/// </summary>
protected override void EndProcessing()
{
var chart = Chart.Plot(_traces);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,42 @@ namespace Microsoft.DotNet.Interactive.PowerShell.Commands
/// </summary>
[Cmdlet(VerbsCommon.New, "PlotlyTrace")]
[OutputType("XPlot.Plotly.Graph+Trace")]
[Alias("npt")]
public sealed class NewPlotlyTraceCommand : PSCmdlet
{
/// <summary>
/// The object from pipeline.
/// The Trace type you want to create.
/// </summary>
[Parameter(Mandatory = true, Position = 0)]
[ValidateSet(
"Area",
"Bar",
"Box",
"Candlestick",
"Choropleth",
"Contour",
"Heatmap",
"Histogram",
"Histogram2d",
"Histogram2dcontour",
"Mesh3d",
"Pie",
"Scatter",
"Scatter3d",
"Scattergeo",
"Scattergl",
"Surface")]
public string TraceType { get; set; }

/// <summary>
/// The name you want to give this Trace.
/// </summary>
[Parameter(Position = 1)]
public string Name { get; set; } = "Untitled";

/// <summary>
/// EndProcessing override.
/// </summary>
protected override void EndProcessing()
{
var trace = CreateTrace(TraceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ namespace Microsoft.DotNet.Interactive.PowerShell.Commands
/// Takes the the input and displays it on the client using .NET Interactive's formatters.
/// This returns a DisplayedValue that can then be updated by calling `Update` on the object.
/// </summary>
[Cmdlet(VerbsCommon.Show, "JupyterContent")]
[Cmdlet(VerbsData.Out, "Display")]
[OutputType("Interactive.Events.DisplayedValue")]
public sealed class ShowJupyterContentCommand : PSCmdlet
[Alias("od")]
public sealed class OutDisplayCommand : PSCmdlet
{
/// <summary>
/// The object from pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.DotNet.Interactive.PowerShell.Commands
/// Takes the the JavaScript string input and invokes it on the client.
/// </summary>
[Cmdlet(VerbsOther.Use, "JavaScript")]
[Alias("uj")]
public sealed class UseJavaScriptCommand : PSCmdlet
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FunctionsToExport = @()
CmdletsToExport = @(
'Get-HtmlContent',
'Use-JavaScript',
'Show-JupyterContent',
'Out-Display',
'Trace-PipelineObject',
'New-PlotlyChart',
'New-PlotlyTrace')
Expand All @@ -60,7 +60,13 @@ CmdletsToExport = @(
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
AliasesToExport = @(
'ghc'
'npc'
'npt'
'od'
'uj'
)

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
Expand Down
6 changes: 3 additions & 3 deletions NotebookExamples/powershell/Docs/HTML.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"metadata": {},
"outputs": [],
"source": [
"Get-HtmlContent '<b style=\"color:blue\">Hello!</b>' | Show-JupyterContent"
"Get-HtmlContent '<b style=\"color:blue\">Hello!</b>' | Out-Display"
]
},
{
Expand All @@ -52,7 +52,7 @@
"metadata": {},
"outputs": [],
"source": [
"Show-JupyterContent '<b style=\"color:blue\">Hello!</b>'"
"Out-Display '<b style=\"color:blue\">Hello!</b>'"
]
},
{
Expand All @@ -70,7 +70,7 @@
"source": [
"$someHtml = Get-HtmlContent '<b style=\"color:blue\">Hello!</b>'\n",
"\n",
"Show-JupyterContent $someHtml.GetType()"
"Out-Display $someHtml.GetType()"
]
},
{
Expand Down

0 comments on commit 6fefff4

Please sign in to comment.