Skip to content

Commit fbe4168

Browse files
committed
Improve status texts
1 parent e11734b commit fbe4168

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/EasySign.CommandLine/BundleWorker.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ protected virtual void RunAdd(StatusContext statusContext)
3333
}
3434

3535
if (!Bundle.IsLoaded && File.Exists(Bundle.BundlePath))
36+
{
37+
statusContext.Status("[yellow]Loading Bundle[/]");
3638
Bundle.LoadFromFile(false);
39+
}
40+
41+
statusContext.Status("[yellow]Adding Files[/]");
3742

3843
Parallel.ForEach(Utilities.SafeEnumerateFiles(Bundle.RootPath, "*"), file =>
3944
{
@@ -58,13 +63,16 @@ protected virtual void RunSign(StatusContext statusContext, X509Certificate2Coll
5863
throw new ApplicationException("Bundle is not initialized");
5964
}
6065

66+
statusContext.Status("[yellow]Loading Bundle[/]");
6167
Bundle.LoadFromFile(false);
6268

6369
int divider = 0;
6470
foreach (var cert in certificates)
6571
{
6672
if (divider++ > 0) AnsiConsole.WriteLine();
6773

74+
statusContext.Status("[yellow]Loading certificate informations[/]");
75+
6876
var grid = new Grid();
6977
grid.AddColumn(new GridColumn().NoWrap());
7078
grid.AddColumn(new GridColumn().PadLeft(2));
@@ -78,16 +86,23 @@ protected virtual void RunSign(StatusContext statusContext, X509Certificate2Coll
7886

7987
AnsiConsole.Write(grid);
8088
AnsiConsole.WriteLine();
89+
90+
statusContext.Status("[yellow]Verifying Certificate[/]");
91+
8192
bool verifyCert = VerifyCertificate(cert);
8293
if (!verifyCert) continue;
8394

95+
statusContext.Status("[yellow]Preparing for signing[/]");
96+
8497
var prvKey = cert.GetRSAPrivateKey();
8598
if (prvKey == null)
8699
{
87100
AnsiConsole.MarkupLine($"[{Color.Green}] Failed to Acquire RSA Private Key[/]");
88101
continue;
89102
}
90103

104+
statusContext.Status("[yellow]Signing Bundle[/]");
105+
91106
Bundle.Sign(cert, prvKey);
92107
AnsiConsole.MarkupLine($"[green] Signing Completed Successfully[/]");
93108
}
@@ -115,8 +130,11 @@ protected virtual void RunVerify(StatusContext statusContext)
115130
["file_error"] = Color.Red3_1,
116131
};
117132

133+
statusContext.Status("[yellow]Loading Bundle[/]");
118134
Bundle.LoadFromFile();
119135

136+
statusContext.Status("[yellow]Verification Phase 1: Certificates and signatures[/]");
137+
120138
int verifiedCerts = 0;
121139
int divider = 0;
122140

@@ -157,7 +175,7 @@ protected virtual void RunVerify(StatusContext statusContext)
157175

158176
AnsiConsole.WriteLine();
159177

160-
statusContext.Status("[yellow]Verifying Files[/]");
178+
statusContext.Status("[yellow]Verification Phase 2: Files[/]");
161179

162180
bool p2Verified = true;
163181

src/EasySign.CommandLine/CommandProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Command Add
4141
command.SetHandler((bundlePath) =>
4242
{
4343
InitializeBundle(bundlePath);
44-
Utilities.RunInStatusContext(ctx => RunAdd(ctx));
44+
Utilities.RunInStatusContext("[yellow]Preparing[/]", ctx => RunAdd(ctx));
4545
}, BundlePath);
4646

4747
return command;
@@ -72,7 +72,7 @@ public Command Sign
7272
InitializeBundle(bundlePath);
7373
X509Certificate2Collection collection = Utilities.GetCertificates(pfxFilePath, pfxFilePassword, pfxNoPasswordPrompt);
7474

75-
Utilities.RunInStatusContext(ctx => RunSign(ctx, collection));
75+
Utilities.RunInStatusContext("[yellow]Preparing[/]", ctx => RunSign(ctx, collection));
7676
}, BundlePath, pfxOpt, pfxPassOpt, pfxNoPassOpt);
7777

7878
return command;
@@ -94,7 +94,7 @@ public Command Verify
9494
command.SetHandler((bundlePath) =>
9595
{
9696
InitializeBundle(bundlePath);
97-
Utilities.RunInStatusContext(ctx => RunVerify(ctx));
97+
Utilities.RunInStatusContext("[yellow]Preparing[/]", ctx => RunVerify(ctx));
9898
}, BundlePath);
9999

100100
return command;

src/EasySign.CommandLine/Utilities.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ public static class Utilities
1717
/// <summary>
1818
/// Runs the specified action within a status context, provides fancy progress showing.
1919
/// </summary>
20+
/// <param name="initialStatus">The initial status being shown at the start of status context. Spectre.Console coloring is supported.</param>
2021
/// <param name="action">The action to run within the status context.</param>
21-
public static void RunInStatusContext(Action<StatusContext> action)
22+
public static void RunInStatusContext(string initialStatus, Action<StatusContext> action)
2223
{
2324
AnsiConsole.Status()
2425
.AutoRefresh(true)
2526
.Spinner(Spinner.Known.Default)
26-
.Start("", action);
27+
.Start(initialStatus, action);
2728
}
2829

2930
/// <summary>

0 commit comments

Comments
 (0)