Skip to content

Commit 9a9935c

Browse files
committed
Change table formatted output to always go to stdout (previously, primitive types went to stdout, compex types + header went to stderr)
1 parent 9cf7442 commit 9a9935c

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
using System.Management.Automation;
7+
8+
namespace Microsoft.CLU.Test
9+
{
10+
[Cmdlet(VerbsCommon.New, "String")]
11+
public class StringGenerator : PSCmdlet
12+
{
13+
public StringGenerator()
14+
{
15+
Count = 10;
16+
StringFormat = "String {0}";
17+
}
18+
19+
[Parameter()]
20+
public int Count { get; set; }
21+
22+
[Parameter()]
23+
public string StringFormat { get; set; }
24+
25+
protected override void ProcessRecord()
26+
{
27+
base.ProcessRecord();
28+
for (int i = 1; i <= Count; ++i)
29+
{
30+
WriteObject(String.Format(StringFormat, i));
31+
}
32+
}
33+
34+
}
35+
}

src/CLU/Microsoft.CLU/System.Management.Automation/Cmdlet.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ internal void FlushPipeline(LocalPackage package)
142142
formattedType = obj.GetType();
143143
if (!wroteHeader)
144144
{
145-
CommandRuntime.WriteCommandDetail(view.FormatHeader(CLUEnvironment.Console.WindowWidth));
146-
CommandRuntime.WriteCommandDetail("");
145+
CommandRuntime.WriteObject(view.FormatHeader(CLUEnvironment.Console.WindowWidth));
146+
CommandRuntime.WriteObject("");
147147
wroteHeader = true;
148148
}
149-
CommandRuntime.WriteCommandDetail(view.FormatObject(obj));
149+
CommandRuntime.WriteObject(view.FormatObject(obj));
150150
}
151151
}
152152
}

0 commit comments

Comments
 (0)