Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<PackageVersion Include="CommandLineParser" Version="2.9.1" />

<!-- ktsu packages -->
<PackageVersion Include="ktsu.IntervalAction" Version="1.3.10" />
<PackageVersion Include="ktsu.AppDataStorage" Version="1.16.14" />
<PackageVersion Include="ktsu.Extensions" Version="1.5.14" />
<PackageVersion Include="ktsu.RunCommand" Version="1.3.5" />
Expand Down
34 changes: 23 additions & 11 deletions KtsuTools.BuildMonitor/BuildMonitorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using Humanizer;
using ktsu.IntervalAction;
using KtsuTools.Core.Services.GitHub;
using Spectre.Console;
using Spectre.Console.Rendering;
Expand Down Expand Up @@ -37,31 +38,42 @@
.AutoClear(true)
.StartAsync(async ctx =>
{
while (!ct.IsCancellationRequested)
TimeSpan interval = TimeSpan.FromSeconds(refreshIntervalSeconds);

void Tick()
{
try
{
Table table = await BuildDashboardTableAsync(owner, ct).ConfigureAwait(false);
Table table = BuildDashboardTableAsync(owner, ct).GetAwaiter().GetResult();
ctx.UpdateTarget(table);
}
catch (OperationCanceledException)
{
break;
}

Check warning on line 52 in KtsuTools.BuildMonitor/BuildMonitorService.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either remove or fill this block of code.

See more on https://sonarcloud.io/project/issues?id=ktsu-dev_KtsuTools&issues=AZ39u_NuDHsPH5Ec2gvc&open=AZ39u_NuDHsPH5Ec2gvc&pullRequest=20
catch (HttpRequestException ex)
{
ctx.UpdateTarget(new Markup($"[red]API Error: {ex.Message.EscapeMarkup()}[/]"));
}
}

try
{
await Task.Delay(TimeSpan.FromSeconds(refreshIntervalSeconds), ct).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
break;
}
Tick();

IntervalAction ticker = IntervalAction.Start(new IntervalActionOptions
{
ActionInterval = interval,
PollingInterval = interval,
Action = Tick,
});

try
{
await Task.Delay(Timeout.InfiniteTimeSpan, ct).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
}

Check warning on line 74 in KtsuTools.BuildMonitor/BuildMonitorService.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either remove or fill this block of code.

See more on https://sonarcloud.io/project/issues?id=ktsu-dev_KtsuTools&issues=AZ39u_NuDHsPH5Ec2gvd&open=AZ39u_NuDHsPH5Ec2gvd&pullRequest=20

ticker.Stop();
}).ConfigureAwait(false);
}

Expand Down
1 change: 1 addition & 0 deletions KtsuTools.BuildMonitor/KtsuTools.BuildMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="Spectre.Console" />
<PackageReference Include="Humanizer.Core" ExcludeAssets="analyzers" />
<PackageReference Include="ktsu.TextFilter" />
<PackageReference Include="ktsu.IntervalAction" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions KtsuTools.CodeGen/CodeGenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public class CodeGenService
public async Task<int> GenerateAsync(AbsoluteFilePath inputFile, string language, AbsoluteFilePath? outputFile = null, CancellationToken ct = default)
#pragma warning restore CA1822
{
Ensure.NotNull(inputFile);
Ensure.NotNull(language);

string fullPath = inputFile.ToString();
Expand Down
2 changes: 2 additions & 0 deletions KtsuTools.FileExplorer/FileExplorerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class FileExplorerService
public async Task<int> RunAsync(AbsoluteDirectoryPath startPath, bool showHidden = false, bool showSizes = true, CancellationToken ct = default)
#pragma warning restore CA1822
{
Ensure.NotNull(startPath);

string currentPath = startPath.ToString();

if (!Directory.Exists(currentPath))
Expand Down
1 change: 1 addition & 0 deletions KtsuTools.Machine/KtsuTools.Machine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="Spectre.Console" />
<PackageReference Include="LibreHardwareMonitorLib" />
<PackageReference Include="Humanizer.Core" ExcludeAssets="analyzers" />
<PackageReference Include="ktsu.IntervalAction" />
</ItemGroup>

<ItemGroup>
Expand Down
41 changes: 22 additions & 19 deletions KtsuTools.Machine/MachineMonitorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ktsu.IntervalAction;
using LibreHardwareMonitor.Hardware;
using Spectre.Console;
using Spectre.Console.Rendering;
Expand Down Expand Up @@ -48,31 +49,33 @@
AnsiConsole.WriteLine();

IRenderable initial = new Text("Loading hardware sensors...");
Computer computerCapture = computer;
await AnsiConsole.Live(initial)
.AutoClear(true)
.StartAsync(async ctx =>
{
while (!ct.IsCancellationRequested)
TimeSpan interval = TimeSpan.FromMilliseconds(refreshIntervalMs);

void Tick() => ctx.UpdateTarget(BuildDashboard(computerCapture));

Tick();

IntervalAction ticker = IntervalAction.Start(new IntervalActionOptions
{
ActionInterval = interval,
PollingInterval = interval,
Action = Tick,
});

try
{
await Task.Delay(Timeout.InfiniteTimeSpan, ct).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
try
{
Table dashboard = BuildDashboard(computer);
ctx.UpdateTarget(dashboard);
}
catch (OperationCanceledException)
{
break;
}

try
{
await Task.Delay(refreshIntervalMs, ct).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
break;
}
}

Check warning on line 76 in KtsuTools.Machine/MachineMonitorService.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either remove or fill this block of code.

See more on https://sonarcloud.io/project/issues?id=ktsu-dev_KtsuTools&issues=AZ39u_KsDHsPH5Ec2gvb&open=AZ39u_KsDHsPH5Ec2gvb&pullRequest=20

ticker.Stop();
}).ConfigureAwait(false);
}
finally
Expand Down
1 change: 1 addition & 0 deletions KtsuTools.MemFrag/KtsuTools.MemFrag.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="Spectre.Console" />
<PackageReference Include="ktsu.IntervalAction" />
</ItemGroup>

<ItemGroup>
Expand Down
40 changes: 27 additions & 13 deletions KtsuTools.MemFrag/MemFragService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using ktsu.IntervalAction;
using Spectre.Console;
using Spectre.Console.Rendering;

Expand Down Expand Up @@ -78,33 +79,46 @@
AnsiConsole.WriteLine();

IRenderable initial = new Text("Loading...");
Process processCapture = process;
await AnsiConsole.Live(initial)
.AutoClear(true)
.StartAsync(async ctx =>
{
while (!ct.IsCancellationRequested)
using CancellationTokenSource exitedCts = CancellationTokenSource.CreateLinkedTokenSource(ct);
TimeSpan interval = TimeSpan.FromMilliseconds(refreshIntervalMs);

void Tick()
{
try
{
process.Refresh();
Table table = BuildMemoryTable(process);
ctx.UpdateTarget(table);
processCapture.Refresh();
ctx.UpdateTarget(BuildMemoryTable(processCapture));
}
catch (InvalidOperationException)
{
ctx.UpdateTarget(new Markup("[red]Process has exited.[/]"));
break;
exitedCts.Cancel();
}
}

try
{
await Task.Delay(refreshIntervalMs, ct).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
break;
}
Tick();

IntervalAction ticker = IntervalAction.Start(new IntervalActionOptions
{
ActionInterval = interval,
PollingInterval = interval,
Action = Tick,
});

try
{
await Task.Delay(Timeout.InfiniteTimeSpan, exitedCts.Token).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
}

Check warning on line 119 in KtsuTools.MemFrag/MemFragService.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either remove or fill this block of code.

See more on https://sonarcloud.io/project/issues?id=ktsu-dev_KtsuTools&issues=AZ39u_N9DHsPH5Ec2gve&open=AZ39u_N9DHsPH5Ec2gve&pullRequest=20

ticker.Stop();
}).ConfigureAwait(false);
}

Expand Down
1 change: 1 addition & 0 deletions KtsuTools.Merge/MergeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class MergeService
public async Task<int> RunMergeAsync(AbsoluteDirectoryPath directory, string filename, CancellationToken ct = default)
#pragma warning restore CA1822
{
Ensure.NotNull(directory);
Ensure.NotNull(filename);

string fullPath = directory.ToString();
Expand Down
2 changes: 2 additions & 0 deletions KtsuTools/Commands/SyncCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public sealed class Settings : CommandSettings
/// </summary>
[CommandOption("--filename <FILENAME>")]
[Description("Filename pattern to scan for. Repeat the flag or pass a comma-separated list to sync several files in one run.")]
#pragma warning disable CA1819 // Properties should not return arrays - Spectre.Console.Cli binds multi-value options via T[] only.
public string[] Filename { get; init; } = [];
#pragma warning restore CA1819

/// <summary>
/// Gets a value indicating whether to push without prompting when all unpushed commits were authored by KtsuTools.
Expand Down
Loading