Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -43,6 +44,8 @@ public CommandLineApplication(bool throwOnUnexpectedArg = true)
public Func<string> LongVersionGetter { get; set; }
public Func<string> ShortVersionGetter { get; set; }
public readonly List<CommandLineApplication> Commands;
public TextWriter Out { get; set; } = Console.Out;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be public? Could these be passed in as constructor arguments instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other switches on this are public, including fields like the one on the line above. Was keeping it consistent.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

public TextWriter Error { get; set; } = Console.Error;

public IEnumerable<CommandOption> GetOptions()
{
Expand Down Expand Up @@ -327,7 +330,7 @@ public void ShowHint()
{
if (OptionHelp != null)
{
Console.WriteLine(string.Format("Specify --{0} for a list of available options and commands.", OptionHelp.LongName));
Out.WriteLine(string.Format("Specify --{0} for a list of available options and commands.", OptionHelp.LongName));
}
}

Expand All @@ -339,7 +342,7 @@ public void ShowHelp(string commandName = null)
cmd.IsShowingInformation = true;
}

Console.WriteLine(GetHelpText(commandName));
Out.WriteLine(GetHelpText(commandName));
}

public virtual string GetHelpText(string commandName = null)
Expand Down Expand Up @@ -451,8 +454,8 @@ public void ShowVersion()
cmd.IsShowingInformation = true;
}

Console.WriteLine(FullName);
Console.WriteLine(LongVersionGetter());
Out.WriteLine(FullName);
Out.WriteLine(LongVersionGetter());
}

public string GetFullNameAndVersion()
Expand All @@ -468,8 +471,8 @@ public void ShowRootCommandFullNameAndVersion()
rootCmd = rootCmd.Parent;
}

Console.WriteLine(rootCmd.GetFullNameAndVersion());
Console.WriteLine();
Out.WriteLine(rootCmd.GetFullNameAndVersion());
Out.WriteLine();
}

private void HandleUnexpectedArg(CommandLineApplication command, string[] args, int index, string argTypeName)
Expand Down