rename project, clean up entrypoint code
This commit is contained in:
@@ -1,25 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34309.116
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "git-anchor", "repo-backup-util\git-anchor.csproj", "{352652F3-958B-416B-B5F5-CDC36B0AA0C4}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "git-anchor", "git-anchor\git-anchor.csproj", "{9B181097-6E9E-4FA1-8167-BFE34C03D08D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{352652F3-958B-416B-B5F5-CDC36B0AA0C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{352652F3-958B-416B-B5F5-CDC36B0AA0C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{352652F3-958B-416B-B5F5-CDC36B0AA0C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{352652F3-958B-416B-B5F5-CDC36B0AA0C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {46CA2A1B-A03D-4D97-9DDF-4BCABF53C54A}
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9B181097-6E9E-4FA1-8167-BFE34C03D08D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9B181097-6E9E-4FA1-8167-BFE34C03D08D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9B181097-6E9E-4FA1-8167-BFE34C03D08D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9B181097-6E9E-4FA1-8167-BFE34C03D08D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
4
git-anchor/Actions/Callable.cs
Normal file
4
git-anchor/Actions/Callable.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace GitAnchor.Actions;
|
||||
delegate Task<ActivityStatusCode> CallableAction();
|
||||
@@ -22,6 +22,10 @@ public class Help : BaseAction
|
||||
Console.WriteLine(" --verbose Prints verbose output.\n");
|
||||
Console.WriteLine("Example: git-anchor pull -v --name=cool-new-backup");
|
||||
|
||||
Console.WriteLine("git-anchor list");
|
||||
Console.WriteLine(" Lists all existing backups.\n");
|
||||
Console.WriteLine("Example: git-anchor list");
|
||||
|
||||
Console.WriteLine("git-anchor find [--regex, -e] [--name, -n <name>]");
|
||||
Console.WriteLine(" Finds an existing backup matching the provided pattern.");
|
||||
Console.WriteLine(" --regex, -e Find your backup directory based on a Regex search.");
|
||||
11
git-anchor/Actions/List.cs
Normal file
11
git-anchor/Actions/List.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace GitAnchor.Actions;
|
||||
class List : BaseAction
|
||||
{
|
||||
static async new Task<ActivityStatusCode> Run()
|
||||
{
|
||||
return ActivityStatusCode.Ok;
|
||||
}
|
||||
|
||||
}
|
||||
31
git-anchor/Program.cs
Normal file
31
git-anchor/Program.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Diagnostics;
|
||||
using GitAnchor.Actions;
|
||||
|
||||
string[] inputArgs = Environment.GetCommandLineArgs();
|
||||
|
||||
SortedDictionary<string, CallableAction> options = new()
|
||||
{
|
||||
{ "create", Create.Run },
|
||||
{ "pull", Pull.Run },
|
||||
{ "help", Help.Run }
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
foreach (string a in inputArgs)
|
||||
{
|
||||
if (a == "") continue;
|
||||
|
||||
var result = options.TryGetValue(a, out CallableAction? action);
|
||||
|
||||
if (!result) continue;
|
||||
if (action != null) return (int)await action();
|
||||
}
|
||||
|
||||
return (int)await Help.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return (int)ActivityStatusCode.Error;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
await GitAnchor.Lib.EntryPoint.Run();
|
||||
@@ -1,38 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using GitAnchor.Actions;
|
||||
|
||||
namespace GitAnchor.Lib;
|
||||
|
||||
public class EntryPoint
|
||||
{
|
||||
public static async Task<ActivityStatusCode> Run()
|
||||
{
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
SortedDictionary<string, Task<ActivityStatusCode>> options = new()
|
||||
{
|
||||
{ "create", Create.Run() },
|
||||
{ "pull", Pull.Run() },
|
||||
{ "help", Help.Run() }
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
foreach (string arg in args)
|
||||
{
|
||||
var result = options.TryGetValue(arg, out Task<ActivityStatusCode>? action);
|
||||
|
||||
if (!result) continue;
|
||||
if (action != null) return await action;
|
||||
}
|
||||
|
||||
return await Help.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return ActivityStatusCode.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user