Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
rename Out to Output
  • Loading branch information
adamsitnik committed Mar 28, 2023
commit 384cae62ee697fe69fbfac7be9f3404e3c1466d9
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ System.CommandLine
public System.Boolean EnablePosixBundling { get; set; }
public System.Boolean EnableTypoCorrections { get; set; }
public System.IO.TextWriter Error { get; set; }
public System.IO.TextWriter Out { get; set; }
public System.IO.TextWriter Output { get; set; }
public System.Nullable<System.TimeSpan> ProcessTerminationTimeout { get; set; }
public System.CommandLine.Parsing.TryReplaceToken ResponseFileTokenReplacer { get; set; }
public Command RootCommand { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Setup()
_configuration = new CommandLineConfiguration(eatCommand)
{
Directives = { new SuggestDirective() },
Out = System.IO.TextWriter.Null
Output = System.IO.TextWriter.Null
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Perf_Parser_TypoCorrection()
_configuration = new CommandLineConfiguration(new RootCommand { option })
{
EnableTypoCorrections = true,
Out = System.IO.TextWriter.Null
Output = System.IO.TextWriter.Null
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task Generated_boolean_parameters_will_accept_zero_arguments()
var config = new CommandLineConfiguration(new RootCommand())
.ConfigureRootCommandFromMethod(
GetMethodInfo(nameof(Method_taking_bool)), this);
config.Out = TextWriter.Null;
config.Output = TextWriter.Null;

await config.InvokeAsync($"{RootCommand.ExecutableName} --value");

Expand All @@ -44,7 +44,7 @@ public async Task Generated_boolean_parameters_will_accept_one_argument(string c
var config = new CommandLineConfiguration(new RootCommand())
.ConfigureRootCommandFromMethod(
GetMethodInfo(nameof(Method_taking_bool)), this);
config.Out = TextWriter.Null;
config.Output = TextWriter.Null;

await config.InvokeAsync(commandLine);

Expand All @@ -57,7 +57,7 @@ public async Task Single_character_parameters_generate_aliases_that_accept_a_sin
var config = new CommandLineConfiguration(new RootCommand())
.ConfigureRootCommandFromMethod(
GetMethodInfo(nameof(Method_with_single_letter_parameters)), this);
config.Out = TextWriter.Null;
config.Output = TextWriter.Null;

await config.InvokeAsync("-x 123 -y 456");

Expand Down Expand Up @@ -164,7 +164,7 @@ public async Task When_method_returns_void_then_return_code_is_0()
var config = new CommandLineConfiguration(new RootCommand())
.ConfigureRootCommandFromMethod(
GetMethodInfo(nameof(Method_returning_void)), this);
config.Out = TextWriter.Null;
config.Output = TextWriter.Null;

var result = await config.InvokeAsync("");

Expand All @@ -177,7 +177,7 @@ public async Task When_method_returns_int_then_return_code_is_set_to_return_valu
var config = new CommandLineConfiguration(new RootCommand())
.ConfigureRootCommandFromMethod(
GetMethodInfo(nameof(Method_returning_int)), this);
config.Out = TextWriter.Null;
config.Output = TextWriter.Null;

var result = await config.InvokeAsync("-i 123");

Expand All @@ -190,7 +190,7 @@ public async Task When_method_returns_Task_of_int_then_return_code_is_set_to_ret
var config = new CommandLineConfiguration(new RootCommand())
.ConfigureRootCommandFromMethod(
GetMethodInfo(nameof(Method_returning_Task_of_int)), this);
config.Out = TextWriter.Null;
config.Output = TextWriter.Null;

var result = await config.InvokeAsync("-i 123");

Expand Down
12 changes: 6 additions & 6 deletions src/System.CommandLine.DragonFruit.Tests/TestProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public class TestProgram
/// <param name="args">These are arguments</param>
public void TestMainWithPara(string name, ParseResult parseResult, string[] args = null)
{
parseResult.Configuration.Out.Write(name);
parseResult.Configuration.Output.Write(name);
if (args != null && args.Length > 0)
{
parseResult.Configuration.Out.Write($"args: { string.Join(",", args) }");
parseResult.Configuration.Output.Write($"args: { string.Join(",", args) }");
}
}

Expand All @@ -43,10 +43,10 @@ public void TestMainWithPara(string name, ParseResult parseResult, string[] args
/// <param name="args">These are arguments</param>
public void TestMainWithTextAndPara(string name, ParseResult parseResult, string[] args = null)
{
parseResult.Configuration.Out.Write(name);
parseResult.Configuration.Output.Write(name);
if (args != null && args.Length > 0)
{
parseResult.Configuration.Out.Write($"args: { string.Join(",", args) }");
parseResult.Configuration.Output.Write($"args: { string.Join(",", args) }");
}
}

Expand All @@ -58,12 +58,12 @@ public void TestMainWithTextAndPara(string name, ParseResult parseResult, string
/// <param name="args">These are arguments</param>
public void TestMainWithoutPara(string name, ParseResult parseResult, string[] args = null)
{
parseResult.Configuration.Out.Write(name);
parseResult.Configuration.Output.Write(name);
}

public void TestMainWithDefault(string name = "Bruce", ParseResult parseResult = null)
{
parseResult?.Configuration.Out.Write(name);
parseResult?.Configuration.Output.Write(name);
}
}
}
4 changes: 2 additions & 2 deletions src/System.CommandLine.DragonFruit/CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static Task<int> InvokeMethodAsync(
TextWriter standardError = null)
{
CommandLineConfiguration configuration = BuildConfiguration(method, xmlDocsFilePath, target);
configuration.Out = standardOutput ?? Console.Out;
configuration.Output = standardOutput ?? Console.Out;
configuration.Error = standardError ?? Console.Error;

return configuration.RootCommand.Parse(args, configuration).InvokeAsync();
Expand All @@ -98,7 +98,7 @@ public static int InvokeMethod(
TextWriter standardError = null)
{
CommandLineConfiguration configuration = BuildConfiguration(method, xmlDocsFilePath, target);
configuration.Out = standardOutput ?? Console.Out;
configuration.Output = standardOutput ?? Console.Out;
configuration.Error = standardError ?? Console.Error;

return configuration.RootCommand.Parse(args, configuration).Invoke();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public async Task Option_arguments_are_bound_by_name_to_method_parameters(
command.Action = handler;
CommandLineConfiguration configuration = new(command)
{
Out = new StringWriter()
Output = new StringWriter()
};

await command.Parse(commandLine, configuration).InvokeAsync(CancellationToken.None);

configuration.Out.ToString().Should().Be(expectedValue.ToString());
configuration.Output.ToString().Should().Be(expectedValue.ToString());
}

[Theory]
Expand Down Expand Up @@ -73,12 +73,12 @@ public async Task Option_arguments_are_bound_by_name_to_the_properties_of_method
command.Action = handler;
CommandLineConfiguration configuration = new(command)
{
Out = new StringWriter()
Output = new StringWriter()
};

await command.Parse(commandLine, configuration).InvokeAsync(CancellationToken.None);

configuration.Out.ToString().Should().Be($"ClassWithSetter<{type.Name}>: {expectedValue}");
configuration.Output.ToString().Should().Be($"ClassWithSetter<{type.Name}>: {expectedValue}");
}

[Theory]
Expand Down Expand Up @@ -107,12 +107,12 @@ public async Task Option_arguments_are_bound_by_name_to_the_constructor_paramete
command.Action = handler;
CommandLineConfiguration configuration = new(command)
{
Out = new StringWriter()
Output = new StringWriter()
};

await command.Parse(commandLine, configuration).InvokeAsync(CancellationToken.None);

configuration.Out.ToString().Should().Be($"ClassWithCtorParameter<{type.Name}>: {expectedValue}");
configuration.Output.ToString().Should().Be($"ClassWithCtorParameter<{type.Name}>: {expectedValue}");
}

[Theory]
Expand All @@ -137,12 +137,12 @@ public async Task Command_arguments_are_bound_by_name_to_handler_method_paramete
command.Action = handler;
CommandLineConfiguration configuration = new(command)
{
Out = new StringWriter()
Output = new StringWriter()
};

await command.Parse(commandLine, configuration).InvokeAsync(CancellationToken.None);

configuration.Out.ToString().Should().Be(expectedValue.ToString());
configuration.Output.ToString().Should().Be(expectedValue.ToString());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ public async Task When_command_suggestions_use_process_that_remains_open_it_retu
var provider = new TestSuggestionRegistration(new Registration(CurrentExeFullPath()));
var dispatcher = new SuggestionDispatcher(provider, new TestSuggestionStore());
dispatcher.Timeout = TimeSpan.FromMilliseconds(1);
dispatcher.Configuration.Out = new StringWriter();
dispatcher.Configuration.Output = new StringWriter();

var args = Parser.SplitCommandLine($@"get -p 0 -e ""{_currentExeName}"" -- {_currentExeName} add").ToArray();

await dispatcher.InvokeAsync(args);

dispatcher.Configuration.Out.ToString().Should().BeEmpty();
dispatcher.Configuration.Output.ToString().Should().BeEmpty();
}

[Fact]
Expand All @@ -151,11 +151,11 @@ public async Task List_command_gets_all_executable_names()
new Registration(_kiwiFruitExeFullPath));

var dispatcher = new SuggestionDispatcher(testSuggestionProvider);
dispatcher.Configuration.Out = new StringWriter();
dispatcher.Configuration.Output = new StringWriter();

await dispatcher.InvokeAsync(new[] { "list" });

dispatcher.Configuration.Out
dispatcher.Configuration.Output
.ToString()
.Should()
.Be($"dotnet-format{Environment.NewLine}dotnet format{Environment.NewLine}kiwi-fruit{Environment.NewLine}");
Expand Down Expand Up @@ -195,9 +195,9 @@ private static async Task<string> InvokeAsync(
ISuggestionStore suggestionStore = null)
{
var dispatcher = new SuggestionDispatcher(suggestionProvider, suggestionStore ?? new TestSuggestionStore());
dispatcher.Configuration.Out = new StringWriter();
dispatcher.Configuration.Output = new StringWriter();
await dispatcher.InvokeAsync(args);
return dispatcher.Configuration.Out.ToString();
return dispatcher.Configuration.Output.ToString();
}

private class TestSuggestionStore : ISuggestionStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ public async Task When_shell_type_is_not_supported_it_throws()
[Fact]
public async Task It_should_print_bash_shell_script()
{
_configuration.Out = new StringWriter();
_configuration.Output = new StringWriter();

await _configuration.InvokeAsync("script bash");

_configuration.Out.ToString().Should().Contain("_dotnet_bash_complete()");
_configuration.Output.ToString().Should().Contain("_dotnet_bash_complete()");
}

[Fact]
public async Task It_should_print_powershell_shell_script()
{
_configuration.Out = new StringWriter();
_configuration.Output = new StringWriter();

await _configuration.InvokeAsync("script powershell");

_configuration.Out.ToString().Should().Contain("Register-ArgumentCompleter");
_configuration.Output.ToString().Should().Contain("Register-ArgumentCompleter");
}

[Fact]
public async Task It_should_print_zsh_shell_script()
{
_configuration.Out = new StringWriter();
_configuration.Output = new StringWriter();

await _configuration.InvokeAsync("script zsh");

_configuration.Out.ToString().Should().Contain("_dotnet_zsh_complete()");
_configuration.Output.ToString().Should().Contain("_dotnet_zsh_complete()");
}
}
}
8 changes: 4 additions & 4 deletions src/System.CommandLine.Suggest/SuggestionDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SuggestionDispatcher(ISuggestionRegistration suggestionRegistration, ISug
};
CompleteScriptCommand.SetAction(context =>
{
SuggestionShellScriptHandler.Handle(context.Configuration.Out, context.GetValue(shellTypeArgument));
SuggestionShellScriptHandler.Handle(context.Configuration.Output, context.GetValue(shellTypeArgument));
});

ListCommand = new Command("list")
Expand All @@ -39,7 +39,7 @@ public SuggestionDispatcher(ISuggestionRegistration suggestionRegistration, ISug
};
ListCommand.SetAction((ctx, cancellationToken) =>
{
ctx.Configuration.Out.WriteLine(ShellPrefixesToMatch(_suggestionRegistration));
ctx.Configuration.Output.WriteLine(ShellPrefixesToMatch(_suggestionRegistration));
return Task.CompletedTask;
});

Expand All @@ -60,7 +60,7 @@ public SuggestionDispatcher(ISuggestionRegistration suggestionRegistration, ISug

RegisterCommand.SetAction((context, cancellationToken) =>
{
Register(context.GetValue(commandPathOption), context.Configuration.Out);
Register(context.GetValue(commandPathOption), context.Configuration.Output);
return Task.CompletedTask;
});

Expand Down Expand Up @@ -178,7 +178,7 @@ private Task<int> Get(ParseResult parseResult, CancellationToken cancellationTok
Program.LogDebug($"dotnet-suggest returning: \"{completions.Replace("\r", "\\r").Replace("\n", "\\n")}\"");
#endif

parseResult.Configuration.Out.Write(completions);
parseResult.Configuration.Output.Write(completions);

return Task.FromResult(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/System.CommandLine.Tests/Binding/TestModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class ClassWithMethodHavingParameter<T>

public ClassWithMethodHavingParameter(ParseResult parseResult)
{
_output = parseResult.Configuration.Out;
_output = parseResult.Configuration.Output;
}

public int Handle(T value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ public void Option_can_customize_first_column_text_based_on_parse_result()
var console = new StringWriter();
var config = new CommandLineConfiguration(command)
{
Out = console
Output = console
};
command.Parse("root a -h", config).Invoke();
console.ToString().Should().Contain(optionAFirstColumnText);

console = new StringWriter();
config.Out = console;
config.Output = console;
command.Parse("root b -h", config).Invoke();
console.ToString().Should().Contain(optionBFirstColumnText);
}
Expand Down Expand Up @@ -146,15 +146,15 @@ public void Option_can_customize_second_column_text_based_on_parse_result()

var config = new CommandLineConfiguration(command)
{
Out = new StringWriter()
Output = new StringWriter()
};

config.Invoke("root a -h");
config.Out.ToString().Should().Contain($"option {optionADescription}");
config.Output.ToString().Should().Contain($"option {optionADescription}");

config.Out = new StringWriter();
config.Output = new StringWriter();
config.Invoke("root b -h");
config.Out.ToString().Should().Contain($"option {optionBDescription}");
config.Output.ToString().Should().Contain($"option {optionBDescription}");
}

[Fact]
Expand Down Expand Up @@ -275,7 +275,7 @@ public void Option_can_fallback_to_default_when_customizing(bool conditionA, boo

CommandLineConfiguration config = new (command);
var console = new StringWriter();
config.Out = console;
config.Output = console;
command.Parse("test -h", config).Invoke();
console.ToString().Should().MatchRegex(expected);
}
Expand Down Expand Up @@ -321,9 +321,9 @@ public void Argument_can_fallback_to_default_when_customizing(
}
});

config.Out = new StringWriter();
config.Output = new StringWriter();
command.Parse("test -h", config).Invoke();
config.Out.ToString().Should().MatchRegex(expected);
config.Output.ToString().Should().MatchRegex(expected);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task Command_InvokeAsync_uses_default_pipeline_by_default()
StringWriter output = new();
CommandLineConfiguration config = new(command)
{
Out = output
Output = output
};

await command.Parse("-h", config).InvokeAsync();
Expand All @@ -50,7 +50,7 @@ public void Command_Invoke_uses_default_pipeline_by_default()
StringWriter output = new ();
CommandLineConfiguration config = new(command)
{
Out = output
Output = output
};

command.Parse("-h", config).Invoke();
Expand Down
Loading