Skip to content

Commit

Permalink
Merge pull request #1794 from microsoft/feat/none_output_option
Browse files Browse the repository at this point in the history
Add none output option
  • Loading branch information
calebkiage authored Aug 25, 2022
2 parents 7436411 + 110d237 commit 7886cb9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added none output formatter to CLI commons. (Shell)

### Changed

- Fix issue with duplicate variable declaration in command handlers (Shell)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Kiota.Cli.Commons.IO;
using Xunit;

namespace Microsoft.Kiota.Cli.Commons.Tests.IO;

public class NoneOutputFormatterTest
{
public class WriteOutputAsyncFunction_Should
{
[Fact]
public async Task Write_No_Content_With_Short_Stream_Content()
{
var formatter = new NoneOutputFormatter();
var content = "Test content";
using var stream = new MemoryStream(Encoding.ASCII.GetBytes(content));
var sb = new StringBuilder();
using var outWriter = new StringWriter(sb);
using var errorWriter = new StringWriter(sb);
Console.SetOut(outWriter);
Console.SetError(errorWriter);

await formatter.WriteOutputAsync(stream, new OutputFormatterOptions());

Assert.Equal(0, sb.Length);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.CommandLine;
using System.Text.Json;
using Spectre.Console;

namespace Microsoft.Kiota.Cli.Commons.IO;

/// <summary>
/// A no-op output formatter
/// </summary>
public class NoneOutputFormatter : IOutputFormatter
{
/// <inheritdoc />
public Task WriteOutputAsync(Stream content, IOutputFormatterOptions? options = null, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/microsoft/kiota</RepositoryUrl>
<Version>0.1.9-preview.2</Version>
<Version>0.1.10-preview.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

Expand Down

0 comments on commit 7886cb9

Please sign in to comment.