From fe2f8244a58c67bef24c2c1a5e6372ca280ca507 Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Tue, 24 Nov 2015 18:26:39 +0000 Subject: [PATCH] Added Write-Progress cmdlet to PSL host code --- src/host/ui.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/host/ui.cs b/src/host/ui.cs index f8c0d4c244..2e84a6312a 100644 --- a/src/host/ui.cs +++ b/src/host/ui.cs @@ -416,10 +416,27 @@ ReadNext: /// /// Unique identifier of the source of the record. /// A ProgressReport object. - public override void WriteProgress(long sourceId, ProgressRecord record) - { + public override void WriteProgress(long sourceId, ProgressRecord record) + { + + if (record == null) + { + throw PSTraceSource.NewArgumentNullException("record"); + } - } + string percentComplete = " ["; + + for (int i =0; i < record.PercentComplete; i++){ + percentComplete = percentComplete + "0"; + } + + percentComplete = percentComplete + "]"; + Console.Write ("\r{0} {1} {2} ", record.Activity, record.StatusDescription, percentComplete, "\r"); + + if (record.PercentComplete == 100){ + Console.WriteLine(); //create a new line for the prompt + } + } /// /// Writes a verbose message to the output display of the host.