forked from gibbed/SteamAchievementManager
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checking in before removing the manager project and moving WPF resour…
…ces out of Core.
- Loading branch information
Showing
33 changed files
with
1,315 additions
and
689 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,84 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using CommandLine; | ||
|
||
namespace SAM.Console; | ||
|
||
public enum ListTarget | ||
{ | ||
Apps, | ||
Stats, | ||
Achievements, | ||
All | ||
} | ||
|
||
public enum ExportTarget | ||
{ | ||
AppList, | ||
Stats, | ||
Achievements, | ||
User, | ||
Settings, | ||
All | ||
} | ||
|
||
public enum StartTarget | ||
{ | ||
SAM, | ||
Steam, | ||
SteamConsole, | ||
SteamApp | ||
} | ||
|
||
public enum OutputFormat | ||
{ | ||
Json = 0, | ||
Text, | ||
Csv, | ||
Xml, | ||
Yml | ||
} | ||
|
||
public abstract class OptionsBase | ||
{ | ||
[Option('f', "format", Default = OutputFormat.Json, HelpText = "The format of the results")] | ||
public OutputFormat Format { get; set; } | ||
|
||
[Option('o', "outfile", HelpText = "The file to save the results to.")] | ||
public string OutFile { get; set; } | ||
|
||
[Option('s', "simple", HelpText = "If set will only show output using plain (non-ANSI) text.")] | ||
public bool SimpleOutput { get; set; } | ||
} | ||
|
||
[Verb("manage", true, HelpText = "List available apps, achievements, stats, and more.")] | ||
public class ManageOptions : OptionsBase | ||
{ | ||
[Option('a', "app", Default = 0, HelpText = "The app's unique Steam ID.")] | ||
[Value(0, Min = 0, MetaName = "app", HelpText = "The app's unique Steam ID.")] | ||
public uint AppId { get; set; } | ||
} | ||
|
||
[Verb("list", false, ["print", "show"], HelpText = "List available apps, achievements, stats, and more.")] | ||
public class ListOptions : OptionsBase | ||
{ | ||
[Option('t', "target", Default = ListTarget.All, HelpText = $"The target type to display")] | ||
public ListTarget Target { get; set; } | ||
} | ||
|
||
[Verb("export", false, ["save"], HelpText = "Export apps, stats, settings, and more.")] | ||
public class ExportOptions : OptionsBase | ||
{ | ||
[Option('t', "target", Default = ListTarget.All, HelpText = $"The information to export")] | ||
public ExportTarget Target { get; set; } | ||
} | ||
|
||
[Verb("start", false, ["run", "launch"], HelpText = "Start Steam, Steam Console, installed app, nad more.")] | ||
public class StartOptions : OptionsBase | ||
{ | ||
[Option('t', "target", Default = StartTarget.SAM, HelpText = $"The target to start")] | ||
public StartTarget Target { get; set; } | ||
} |
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,47 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using CommandLine; | ||
using log4net; | ||
using SAM.Console; | ||
|
||
var log = LogManager.GetLogger(nameof(Program)); | ||
|
||
var helpWriter = new StringWriter(); | ||
var parser = new Parser(with => | ||
{ | ||
//ignore case for enum values | ||
with.CaseInsensitiveEnumValues = true; | ||
with.HelpWriter = helpWriter; | ||
}); | ||
|
||
var options = parser.ParseArguments<ManageOptions, ListOptions, StartOptions>(Environment.GetCommandLineArgs()) | ||
.WithParsed<ManageOptions>(HandleManage) | ||
.WithParsed<ListOptions>(opts => opts.ToString()) | ||
.WithParsed<StartOptions>(opts => opts.ToString()) | ||
.WithNotParsed(errs => DisplayHelp(errs, helpWriter)); | ||
|
||
Console.WriteLine("Hello, World!"); | ||
|
||
// ReSharper disable once InconsistentNaming | ||
static void DisplayHelp(IEnumerable<Error> err, TextWriter helpWriter) | ||
{ | ||
var errors = err.ToList(); | ||
|
||
if (errors.IsVersion() || errors.IsHelp()) | ||
{ | ||
Console.WriteLine(helpWriter.ToString()); | ||
} | ||
else | ||
{ | ||
Console.Error.WriteLine(helpWriter.ToString()); | ||
} | ||
} | ||
|
||
static void HandleManage(ManageOptions options) | ||
{ | ||
|
||
} |
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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CommandLineParser" Version="2.9.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\SAM.Core\SAM.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</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
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
Oops, something went wrong.