-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clipboard service + Argument parser
- Loading branch information
Showing
5 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.ComponentModel; | ||
using Ookii.CommandLine; | ||
|
||
namespace SteamAuth | ||
{ | ||
[ParseOptions( | ||
Mode = ParsingMode.LongShort, | ||
CaseSensitive = false, | ||
ArgumentNameTransform = NameTransform.DashCase, | ||
ValueDescriptionTransform = NameTransform.DashCase | ||
)] | ||
[Description("Generates a steam TOTP code using a provided secret.")] | ||
public class Arguments | ||
{ | ||
|
||
[CommandLineArgument(Position = 0, IsRequired = false)] | ||
[Description("Steam TOTP secret")] | ||
public string? Secret { get; set; } | ||
|
||
[CommandLineArgument(IsRequired = false, ShortName = 's')] | ||
[Description("Whether to save the encrypted secret to a config file")] | ||
public bool Save { get; set; } | ||
|
||
internal bool IsInvalid { get; private set; } | ||
|
||
public Arguments() | ||
{ | ||
Secret = null; | ||
Save = false; | ||
} | ||
|
||
internal Arguments(bool isInvalid) : this() | ||
{ | ||
IsInvalid = isInvalid; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Version>0.0.2</Version> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RootNamespace>SteamAuth</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<WarningsAsErrors>Nullable</WarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
<PublishReadyToRun>true</PublishReadyToRun> | ||
<PublishTrimmed>true</PublishTrimmed> | ||
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CrossPlatformProtectedData" Version="1.0.3" /> | ||
<PackageReference Include="Ookii.CommandLine" Version="3.0.0" /> | ||
<PackageReference Include="SteamGuard.TOTP" Version="1.0.0" /> | ||
<PackageReference Include="TextCopy" Version="6.2.1" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Ookii.CommandLine.Terminal; | ||
|
||
namespace SteamAuth.Utils | ||
{ | ||
public class ConsoleWriter : IDisposable | ||
{ | ||
private readonly VirtualTerminalSupport virtualTerminal; | ||
private readonly bool _formatSupported = false; | ||
|
||
public ConsoleWriter() | ||
{ | ||
virtualTerminal = VirtualTerminal.EnableColor(StandardStream.Output); | ||
_formatSupported = virtualTerminal.IsSupported; | ||
} | ||
|
||
public void Write(string text, params string[] formats) | ||
{ | ||
if (_formatSupported) | ||
{ | ||
Console.Write(formats); | ||
} | ||
|
||
Console.Write(text); | ||
} | ||
|
||
public void WriteLine(string text, params string[] formats) | ||
{ | ||
if (_formatSupported) | ||
{ | ||
Console.Write(string.Concat(formats)); | ||
} | ||
|
||
Console.WriteLine(text); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
virtualTerminal.Dispose(); | ||
GC.SuppressFinalize(this); | ||
} | ||
} | ||
} |