PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.TextStatusSteps Class Reference

Provides an easy mechanism for steps of a process with status feedback, ie "starting X..." / {does X} / {"completed" / "failed"}. More...

Inheritance diagram for PeanutButter.Utils.TextStatusSteps:
PeanutButter.Utils.ITextStatusSteps PeanutButter.Utils.SuppressedTextStatusSteps

Public Member Functions

 TextStatusSteps ()
 Create the default status steps with no per-activity prefix and the pass/fail indicators [ OK ] and [FAIL].
 
 TextStatusSteps (string prefixAllStatusLines, string startMarker, string completedMarker, string failedMarker)
 Create the status steps with:
 
 TextStatusSteps (string prefixAllStatusLines, string startMarker, string completedMarker, string failedMarker, Action< string > writer)
 Create the status steps with:
 
 TextStatusSteps (string prefixAllStatusLines, string startMarker, string completedMarker, string failedMarker, Action< string > writer, Action flushAction)
 Create the status steps with:
 
 TextStatusSteps (string prefixAllStatusLines, string startMarker, string completedMarker, string failedMarker, Action< string > writer, Action flushAction, Func< Exception, ErrorHandlerResult > exceptionHandler)
 Create the status steps with:
 
 TextStatusSteps (Func< string > prefixAllStatusLines, string startMarker, string completedMarker, string failedMarker, Action< string > writer, Action flushAction, Func< Exception, ErrorHandlerResult > exceptionHandler)
 Create the status steps with:
 
 TextStatusSteps (Func< string > prefixAllStatusLines, string startMarker, string completedMarker, string failedMarker, Func< string, Task > asyncWriter, Func< Task > asyncFlushAction, Func< Exception, Task< ErrorHandlerResult > > asyncExceptionHandler)
 Create the status steps with:
 
void Run (string label, Action activity)
 Run the provided activity with the given label.
Parameters
label
activity

 
async Task RunAsync (string label, Func< Task > activity)
 Run the provided async activity with the given label.
Parameters
label
activity

 
void Log (string str)
 Simply log within the context of the steps (ie with the same io & prefixing)
Parameters
str

 
async Task LogAsync (string str)
 Simply log within the context of the steps (ie with the same io & prefixing)
Parameters
str

 

Static Public Attributes

const string DEFAULT_OK_LABEL = "[ OK ]"
 The default label applied to activities that complete successfully eg "[ OK ] Fetching the stuff".
 
const string DEFAULT_FAIL_LABEL = "[FAIL]"
 The default label applied to activities that fail eg "[FAIL] Fetching the stuff".
 
const string DEFAULT_START_LABEL = "[ -- ]"
 The default label applied when starting your activity eg "[ – ] Fetching the stuff.
 

Detailed Description

Provides an easy mechanism for steps of a process with status feedback, ie "starting X..." / {does X} / {"completed" / "failed"}.

Constructor & Destructor Documentation

◆ TextStatusSteps() [1/6]

PeanutButter.Utils.TextStatusSteps.TextStatusSteps ( string  prefixAllStatusLines,
string  startMarker,
string  completedMarker,
string  failedMarker 
)

Create the status steps with:

  • a default prefix (eg "Starting")
  • a completed marker (eg "[ OK ]" or "✔️")
  • a failed marker (eg "[FAIL]" or "❌")
Parameters
prefixAllStatusLines
startMarker
completedMarker
failedMarker

◆ TextStatusSteps() [2/6]

PeanutButter.Utils.TextStatusSteps.TextStatusSteps ( string  prefixAllStatusLines,
string  startMarker,
string  completedMarker,
string  failedMarker,
Action< string >  writer 
)

Create the status steps with:

  • a default prefix (eg "Starting")
  • a completed marker (eg "[ OK ]" or "✔️")
  • a failed marker (eg "[FAIL]" or "❌")
  • a callback to write status information
Parameters
prefixAllStatusLines
startMarker
completedMarker
failedMarker
writer

◆ TextStatusSteps() [3/6]

PeanutButter.Utils.TextStatusSteps.TextStatusSteps ( string  prefixAllStatusLines,
string  startMarker,
string  completedMarker,
string  failedMarker,
Action< string >  writer,
Action  flushAction 
)

Create the status steps with:

  • a default prefix (eg "Starting")
  • a completed marker (eg "[ OK ]" or "✔️")
  • a failed marker (eg "[FAIL]" or "❌")
  • a callback to write status information
  • a callback to flush status information when appropriate
    • this is only necessary if your writer callback buffers
Parameters
prefixAllStatusLines
startMarker
completedMarker
failedMarker
writer
flushAction

◆ TextStatusSteps() [4/6]

PeanutButter.Utils.TextStatusSteps.TextStatusSteps ( string  prefixAllStatusLines,
string  startMarker,
string  completedMarker,
string  failedMarker,
Action< string >  writer,
Action  flushAction,
Func< Exception, ErrorHandlerResult exceptionHandler 
)

Create the status steps with:

  • a default prefix (eg "Starting")
  • a completed marker (eg "[ OK ]" or "✔️")
  • a failed marker (eg "[FAIL]" or "❌")
  • a callback to write status information
  • a callback to flush status information when appropriate
    • this is only necessary if your writer callback buffers
Parameters
prefixAllStatusLinesPrefix all status lines with this (after the start/ok/fail marker)
startMarkerMarker/placeholder when activity starts
completedMarkerMarker for a completed activity
failedMarkerMarker for a failed activity
writerAction to call to write a message
flushActionAction to call to flush any buffered messages
exceptionHandler(optional) - if provided, if an error is thrown by the activity, this is invoked. If this returns true, the exception will be rethrown, otherwise it will be suppressed

◆ TextStatusSteps() [5/6]

PeanutButter.Utils.TextStatusSteps.TextStatusSteps ( Func< string >  prefixAllStatusLines,
string  startMarker,
string  completedMarker,
string  failedMarker,
Action< string >  writer,
Action  flushAction,
Func< Exception, ErrorHandlerResult exceptionHandler 
)

Create the status steps with:

  • a default prefix (eg "Starting")
  • a completed marker (eg "[ OK ]" or "✔️")
  • a failed marker (eg "[FAIL]" or "❌")
  • a callback to write status information
  • a callback to flush status information when appropriate
    • this is only necessary if your writer callback buffers
Parameters
prefixAllStatusLinesPrefix all status lines with this (after the start/ok/fail marker)
startMarkerMarker/placeholder when activity starts
completedMarkerMarker for a completed activity
failedMarkerMarker for a failed activity
writerAction to call to write a message
flushActionAction to call to flush any buffered messages
exceptionHandler(optional) - if provided, if an error is thrown by the activity, this is invoked. If this returns true, the exception will be rethrown, otherwise it will be suppressed

◆ TextStatusSteps() [6/6]

PeanutButter.Utils.TextStatusSteps.TextStatusSteps ( Func< string >  prefixAllStatusLines,
string  startMarker,
string  completedMarker,
string  failedMarker,
Func< string, Task >  asyncWriter,
Func< Task >  asyncFlushAction,
Func< Exception, Task< ErrorHandlerResult > >  asyncExceptionHandler 
)

Create the status steps with:

  • a default prefix (eg "Starting")
  • a completed marker (eg "[ OK ]" or "✔️")
  • a failed marker (eg "[FAIL]" or "❌")
  • a callback to write status information
  • a callback to flush status information when appropriate
    • this is only necessary if your writer callback buffers
Parameters
prefixAllStatusLinesPrefix all status lines with this (after the start/ok/fail marker)
startMarkerMarker/placeholder when activity starts
completedMarkerMarker for a completed activity
failedMarkerMarker for a failed activity
asyncWriterAction to call to write a message
asyncFlushActionAction to call to flush any buffered messages
asyncExceptionHandler(optional) - if provided, if an error is thrown by the activity, this is invoked. If this returns true, the exception will be rethrown, otherwise it will be suppressed

Member Function Documentation

◆ Log()

void PeanutButter.Utils.TextStatusSteps.Log ( string  str)

Simply log within the context of the steps (ie with the same io & prefixing)

Parameters
str

Implements PeanutButter.Utils.ITextStatusSteps.

◆ LogAsync()

async Task PeanutButter.Utils.TextStatusSteps.LogAsync ( string  str)

Simply log within the context of the steps (ie with the same io & prefixing)

Parameters
str

Implements PeanutButter.Utils.ITextStatusSteps.

◆ Run()

void PeanutButter.Utils.TextStatusSteps.Run ( string  label,
Action  activity 
)

Run the provided activity with the given label.

Parameters
label
activity

Implements PeanutButter.Utils.ITextStatusSteps.

◆ RunAsync()

async Task PeanutButter.Utils.TextStatusSteps.RunAsync ( string  label,
Func< Task >  activity 
)

Run the provided async activity with the given label.

Parameters
label
activity

Implements PeanutButter.Utils.ITextStatusSteps.


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