This commit is contained in:
Tyrrrz
2021-03-31 11:40:37 +03:00
parent 17ded54e24
commit 8d7d25a144
6 changed files with 13 additions and 13 deletions

View File

@@ -16,7 +16,7 @@
public string ExecutableName { get; } public string ExecutableName { get; }
/// <summary> /// <summary>
/// Application version text. /// Application version.
/// </summary> /// </summary>
public string Version { get; } public string Version { get; }

View File

@@ -99,7 +99,7 @@ namespace CliFx
// Handle preview directive // Handle preview directive
if (IsPreviewModeEnabled(commandInput)) if (IsPreviewModeEnabled(commandInput))
{ {
_console.WriteCommandInput(commandInput); _console.Output.WriteCommandInput(commandInput);
return 0; return 0;
} }
@@ -125,7 +125,7 @@ namespace CliFx
// Handle help option // Handle help option
if (ShouldShowHelpText(commandSchema, commandInput)) if (ShouldShowHelpText(commandSchema, commandInput))
{ {
_console.WriteHelpText(helpContext); _console.Output.WriteHelpText(helpContext);
return 0; return 0;
} }
@@ -150,12 +150,12 @@ namespace CliFx
} }
catch (CliFxException ex) catch (CliFxException ex)
{ {
_console.WriteException(ex); _console.Error.WriteException(ex);
if (ex.ShowHelp) if (ex.ShowHelp)
{ {
_console.Output.WriteLine(); _console.Output.WriteLine();
_console.WriteHelpText(helpContext); _console.Output.WriteHelpText(helpContext);
} }
return ex.ExitCode; return ex.ExitCode;
@@ -200,7 +200,7 @@ namespace CliFx
// developer, so we don't swallow them in that case. // developer, so we don't swallow them in that case.
catch (Exception ex) when (!Debugger.IsAttached) catch (Exception ex) when (!Debugger.IsAttached)
{ {
_console.WriteException(ex); _console.Error.WriteException(ex);
return 1; return 1;
} }
} }

View File

@@ -37,7 +37,7 @@ namespace CliFx
} }
/// <summary> /// <summary>
/// Adds a command the application. /// Adds a command to the application.
/// </summary> /// </summary>
public CliApplicationBuilder AddCommand<TCommand>() where TCommand : ICommand => public CliApplicationBuilder AddCommand<TCommand>() where TCommand : ICommand =>
AddCommand(typeof(TCommand)); AddCommand(typeof(TCommand));

View File

@@ -93,7 +93,7 @@ namespace CliFx.Formatting
internal static class CommandInputConsoleFormatterExtensions internal static class CommandInputConsoleFormatterExtensions
{ {
public static void WriteCommandInput(this IConsole console, CommandInput commandInput) => public static void WriteCommandInput(this ConsoleWriter consoleWriter, CommandInput commandInput) =>
new CommandInputConsoleFormatter(console.Output).WriteCommandInput(commandInput); new CommandInputConsoleFormatter(consoleWriter).WriteCommandInput(commandInput);
} }
} }

View File

@@ -129,7 +129,7 @@ namespace CliFx.Formatting
internal static class ExceptionConsoleFormatterExtensions internal static class ExceptionConsoleFormatterExtensions
{ {
public static void WriteException(this IConsole console, Exception exception) => public static void WriteException(this ConsoleWriter consoleWriter, Exception exception) =>
new ExceptionConsoleFormatter(console.Error).WriteException(exception); new ExceptionConsoleFormatter(consoleWriter).WriteException(exception);
} }
} }

View File

@@ -443,7 +443,7 @@ namespace CliFx.Formatting
internal static class HelpConsoleFormatterExtensions internal static class HelpConsoleFormatterExtensions
{ {
public static void WriteHelpText(this IConsole console, HelpContext context) => public static void WriteHelpText(this ConsoleWriter consoleWriter, HelpContext context) =>
new HelpConsoleFormatter(console.Output, context).WriteHelpText(); new HelpConsoleFormatter(consoleWriter, context).WriteHelpText();
} }
} }