WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 26634c9

Browse files
authored
Merge pull request #65 from CycloneDX/issue61
Fix analyze command output line endings on Windows
2 parents 119c206 + 606dc45 commit 26634c9

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

cyclonedx/Commands/Convert/AnalyzeCommand.cs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ public static async Task<int> Analyze(
7272
}
7373
}
7474

75-
string outputString;
76-
7775
if (outputFormat == StandardOutputFormat.json)
7876
{
7977
var options = new JsonSerializerOptions
@@ -93,41 +91,35 @@ public static async Task<int> Analyze(
9391
options.Converters.Add(new Json.v1_2.Converters.LicenseConverter());
9492
options.Converters.Add(new Json.v1_2.Converters.PatchClassificationConverter());
9593

96-
outputString = JsonSerializer.Serialize(result, options);
94+
Console.WriteLine(JsonSerializer.Serialize(result, options));
9795
}
9896
else
9997
{
100-
var sb = new StringBuilder();
101-
10298
if (result.MultipleComponentVersions != null)
10399
{
104-
sb.AppendLine("Components with multiple versions:");
105-
sb.AppendLine();
100+
Console.WriteLine("Components with multiple versions:");
101+
Console.WriteLine();
106102
if (result.MultipleComponentVersions.Count == 0)
107103
{
108-
sb.AppendLine("None");
104+
Console.WriteLine("None");
109105
}
110106
else
111107
{
112108
foreach (var componentEntry in result.MultipleComponentVersions)
113109
{
114-
sb.Append(componentEntry.First().Name);
115-
sb.Append(" versions:");
110+
Console.Write(componentEntry.First().Name);
111+
Console.Write(" versions:");
116112
foreach (var component in componentEntry)
117113
{
118-
sb.Append(" ");
119-
sb.Append(component.Version);
114+
Console.Write(" ");
115+
Console.Write(component.Version);
120116
}
121117
}
122118
}
123-
sb.AppendLine();
119+
Console.WriteLine();
124120
}
125-
126-
outputString = sb.ToString();
127121
}
128122

129-
Console.Write(outputString);
130-
131123
return (int)ExitCode.Ok;
132124
}
133125
}

0 commit comments

Comments
 (0)