diff --git a/src/abstractions/CommandTree/DefaultHelpTextCommand.cs b/src/abstractions/CommandTree/DefaultHelpTextCommand.cs index feeee14..7b85e26 100644 --- a/src/abstractions/CommandTree/DefaultHelpTextCommand.cs +++ b/src/abstractions/CommandTree/DefaultHelpTextCommand.cs @@ -22,7 +22,7 @@ namespace Shamir.Abstractions public ValueTask ExecuteAsync(IServiceProvider serviceProvider) { - System.Console.Error.WriteLine(GetHelpText()); + Console.Error.WriteLine(GetHelpText()); return ValueTask.FromResult(1); // TODO: const } diff --git a/src/abstractions/ParsedArgumentsCommand.cs b/src/abstractions/ParsedArgumentsCommand.cs index 9a92c4c..2218289 100644 --- a/src/abstractions/ParsedArgumentsCommand.cs +++ b/src/abstractions/ParsedArgumentsCommand.cs @@ -29,7 +29,7 @@ namespace Shamir.Abstractions var helpText = HelpText.AutoBuild(result); helpText.Heading = string.Empty; helpText.Copyright = string.Empty; - System.Console.Error.WriteLine(helpText); + Console.Error.WriteLine(helpText); return ValueTask.FromResult(1); } ); diff --git a/src/commands/radio/VKLookupCommand.cs b/src/commands/radio/VKLookupCommand.cs index 27ed417..0cc7d6b 100644 --- a/src/commands/radio/VKLookupCommand.cs +++ b/src/commands/radio/VKLookupCommand.cs @@ -35,7 +35,7 @@ namespace Shamir.Commands.Radio if (response.StatusCode == HttpStatusCode.NotFound) { - System.Console.WriteLine($"{options.Callsign}: No such callsign found."); + Console.WriteLine($"{options.Callsign}: No such callsign found."); return 1; } @@ -46,32 +46,32 @@ namespace Shamir.Commands.Radio if (json.RootElement.TryGetProperty("callsign", out var callsign)) { - System.Console.Write("Callsign : "); - System.Console.WriteLine(callsign.GetString()); + Console.Write("Callsign : "); + Console.WriteLine(callsign.GetString()); } if (json.RootElement.TryGetProperty("name", out var name)) { - System.Console.Write("Name : "); - System.Console.WriteLine(name.GetString()); + Console.Write("Name : "); + Console.WriteLine(name.GetString()); } if (json.RootElement.TryGetProperty("suburb", out var suburb)) { - System.Console.Write("Suburb : "); - System.Console.WriteLine(suburb.GetString()); + Console.Write("Suburb : "); + Console.WriteLine(suburb.GetString()); } if (json.RootElement.TryGetProperty("state", out var state)) { - System.Console.Write("State : "); - System.Console.WriteLine(state.GetString()); + Console.Write("State : "); + Console.WriteLine(state.GetString()); } if (json.RootElement.TryGetProperty("link", out var link)) { - System.Console.Write("Link : "); - System.Console.WriteLine(link.GetString()); + Console.Write("Link : "); + Console.WriteLine(link.GetString()); } return 0; diff --git a/src/commands/steam/DescribeGidCommand.cs b/src/commands/steam/DescribeGidCommand.cs new file mode 100644 index 0000000..c579ec8 --- /dev/null +++ b/src/commands/steam/DescribeGidCommand.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading.Tasks; +using CommandLine; +using Shamir.Abstractions; +using SteamKit2; + +namespace Shamir.Commands.Radio +{ + public class DescribeGidOptions + { + [Value(0, MetaName = "gid", Required = true, HelpText = "Global ID to describe.")] + public ulong Gid { get; set; } + } + + public sealed class DescribeGidCommand : ParsedArgumentsCommand + { + public override string Name => "gid"; + + public override string Description => "Explain a gid_t (Global ID)"; + + public override ValueTask ExecuteAsync(IServiceProvider serviceProvider, DescribeGidOptions options) + { + var gid = new GlobalID(options.Gid); + + Console.WriteLine($"Box ID : {gid.BoxID}"); + Console.WriteLine($"Process ID : {gid.ProcessID}"); + Console.WriteLine($"Process Start Time : {gid.StartTime}"); + Console.WriteLine($"Sequence : {gid.SequentialCount}"); + + return ValueTask.FromResult(0); + } + } +} \ No newline at end of file diff --git a/src/commands/steam/ServiceCollectionExtensions.cs b/src/commands/steam/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..2afbf3f --- /dev/null +++ b/src/commands/steam/ServiceCollectionExtensions.cs @@ -0,0 +1,22 @@ +using System.Collections.Immutable; +using Microsoft.Extensions.DependencyInjection; +using Shamir.Abstractions; + +namespace Shamir.Commands.Radio +{ + public static class ServiceCollectionExtensions + { + public static IServiceCollection AddSteamCommandTree(this IServiceCollection collection) + { + collection.AddTransient(sp => new DefaultCommandTree( + "steam", + "Steam Network utilities", + ImmutableArray.Empty, + ImmutableArray.Create( + new DescribeGidCommand() + ))); + + return collection; + } + } +} \ No newline at end of file diff --git a/src/commands/steam/steam.csproj b/src/commands/steam/steam.csproj index ef9b097..16c846a 100644 --- a/src/commands/steam/steam.csproj +++ b/src/commands/steam/steam.csproj @@ -4,10 +4,15 @@ net5.0 Shamir.Commands.Steam Shamir.Commands.Steam + enable + + + + diff --git a/src/console/Program.cs b/src/console/Program.cs index ceaa443..f36fea5 100644 --- a/src/console/Program.cs +++ b/src/console/Program.cs @@ -23,6 +23,7 @@ namespace Shamir.Console })) .AddAzureCommandTree() .AddRadioCommandTree() + .AddSteamCommandTree() .BuildServiceProvider(); using var scope = serviceProvider.CreateScope();