NanoByte.Common 2.10.6
NanoByte.Common.Tasks.CliTaskHandler Class Reference

Informs the user about the progress of tasks and ask questions using console output. More...

Inheritance diagram for NanoByte.Common.Tasks.CliTaskHandler:
NanoByte.Common.Tasks.TaskHandlerBase NanoByte.Common.Tasks.ITaskHandler NanoByte.Common.Tasks.AnsiCliTaskHandler

Public Member Functions

 CliTaskHandler ()
 Creates a new CLI task handler. Registers a Log.Handler and a Console.CancelKeyPress handler.
 
override void Dispose ()
 Unregisters the Log.Handler and the Console.CancelKeyPress handler. More...
 
override void RunTask (ITask task)
 Runs an ITask and tracks its progress. Returns once the task has been completed. More...
 
override void Output (string title, string message)
 Displays multi-line text to the user. More...
 
override void Error (Exception exception)
 Displays an error message to the user. More...
 
- Public Member Functions inherited from NanoByte.Common.Tasks.TaskHandlerBase
bool Ask (string question, bool? defaultAnswer=null, string? alternateMessage=null)
 Asks the user a Yes/No/Cancel question. More...
 
virtual void Output< T > (string title, IEnumerable< T > data)
 Displays tabular data to the user. More...
 
virtual void Output< T > (string title, NamedCollection< T > data)
 Displays tree-like data to the user. More...
 

Protected Member Functions

virtual void LogHandler (LogSeverity severity, string message)
 Prints Log messages to the Console based on their LogSeverity and the current Verbosity level. More...
 
override bool AskInteractive (string question, bool defaultAnswer)
 Asks the user a Yes/No/Cancel question. More...
 

Properties

override? ICredentialProvider CredentialProvider [get]
 
override bool IsInteractive [get]
 
- Properties inherited from NanoByte.Common.Tasks.TaskHandlerBase
CancellationTokenSource CancellationTokenSource = new() [get]
 Used to signal the CancellationToken.
 
CancellationToken CancellationToken [get]
 
virtual ? ICredentialProvider CredentialProvider [get]
 
Verbosity Verbosity [getset]
 
virtual bool IsInteractive [get]
 Indicates whether the user can provide input.
 
- Properties inherited from NanoByte.Common.Tasks.ITaskHandler
CancellationToken CancellationToken [get]
 Used to signal when the user wishes to cancel the entire current process (and any ITasks it includes). More...
 
ICredentialProviderCredentialProvider [get]
 Used to ask the user or a keyring for NetworkCredentials for specific Uris; can be null.
 
Verbosity Verbosity [getset]
 The detail level of messages displayed to the user.
 

Detailed Description

Informs the user about the progress of tasks and ask questions using console output.

This class is thread-safe.

Member Function Documentation

◆ AskInteractive()

override bool NanoByte.Common.Tasks.CliTaskHandler.AskInteractive ( string  question,
bool  defaultAnswer 
)
inlineprotectedvirtual

Asks the user a Yes/No/Cancel question.

Implements NanoByte.Common.Tasks.TaskHandlerBase.

◆ Dispose()

override void NanoByte.Common.Tasks.CliTaskHandler.Dispose ( )
inlinevirtual

Unregisters the Log.Handler and the Console.CancelKeyPress handler.

Reimplemented from NanoByte.Common.Tasks.TaskHandlerBase.

◆ Error()

override void NanoByte.Common.Tasks.CliTaskHandler.Error ( Exception  exception)
virtual

Displays an error message to the user.

Implements NanoByte.Common.Tasks.TaskHandlerBase.

◆ LogHandler()

virtual void NanoByte.Common.Tasks.CliTaskHandler.LogHandler ( LogSeverity  severity,
string  message 
)
inlineprotectedvirtual

Prints Log messages to the Console based on their LogSeverity and the current Verbosity level.

Parameters
severityThe type/severity of the entry.
messageThe message text of the entry.

Reimplemented in NanoByte.Common.Tasks.AnsiCliTaskHandler.

◆ Output()

override void NanoByte.Common.Tasks.CliTaskHandler.Output ( string  title,
string  message 
)
inlinevirtual

Displays multi-line text to the user.

Implements NanoByte.Common.Tasks.TaskHandlerBase.

◆ RunTask()

override void NanoByte.Common.Tasks.CliTaskHandler.RunTask ( ITask  task)
inlinevirtual

Runs an ITask and tracks its progress. Returns once the task has been completed.

Reimplemented from NanoByte.Common.Tasks.TaskHandlerBase.


The documentation for this class was generated from the following file: