From 29643ae86d2a5d760d330dd8740773a85a1a9152 Mon Sep 17 00:00:00 2001 From: Mikayla Dobson Date: Sat, 27 Jan 2024 10:56:44 -0600 Subject: [PATCH] rename project, clean up entrypoint code --- git-anchor.sln | 17 ++++----- .../Actions/Base.cs | 0 git-anchor/Actions/Callable.cs | 4 ++ .../Actions/Create.cs | 0 .../Actions/Help.cs | 4 ++ git-anchor/Actions/List.cs | 11 ++++++ .../Actions/Pull.cs | 0 .../lib => git-anchor/Lib}/CommandLine.cs | 0 .../lib => git-anchor/Lib}/FileSystem.cs | 0 .../lib => git-anchor/Lib}/GitHub.cs | 0 .../lib => git-anchor/Lib}/Volumes.cs | 0 git-anchor/Program.cs | 31 +++++++++++++++ .../git-anchor.csproj | 0 repo-backup-util/Program.cs | 1 - repo-backup-util/lib/Entrypoint.cs | 38 ------------------- 15 files changed, 57 insertions(+), 49 deletions(-) rename {repo-backup-util => git-anchor}/Actions/Base.cs (100%) create mode 100644 git-anchor/Actions/Callable.cs rename {repo-backup-util => git-anchor}/Actions/Create.cs (100%) rename {repo-backup-util => git-anchor}/Actions/Help.cs (91%) create mode 100644 git-anchor/Actions/List.cs rename {repo-backup-util => git-anchor}/Actions/Pull.cs (100%) rename {repo-backup-util/lib => git-anchor/Lib}/CommandLine.cs (100%) rename {repo-backup-util/lib => git-anchor/Lib}/FileSystem.cs (100%) rename {repo-backup-util/lib => git-anchor/Lib}/GitHub.cs (100%) rename {repo-backup-util/lib => git-anchor/Lib}/Volumes.cs (100%) create mode 100644 git-anchor/Program.cs rename {repo-backup-util => git-anchor}/git-anchor.csproj (100%) delete mode 100644 repo-backup-util/Program.cs delete mode 100644 repo-backup-util/lib/Entrypoint.cs diff --git a/git-anchor.sln b/git-anchor.sln index 0edb8a0..4c77167 100644 --- a/git-anchor.sln +++ b/git-anchor.sln @@ -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 diff --git a/repo-backup-util/Actions/Base.cs b/git-anchor/Actions/Base.cs similarity index 100% rename from repo-backup-util/Actions/Base.cs rename to git-anchor/Actions/Base.cs diff --git a/git-anchor/Actions/Callable.cs b/git-anchor/Actions/Callable.cs new file mode 100644 index 0000000..418ccfe --- /dev/null +++ b/git-anchor/Actions/Callable.cs @@ -0,0 +1,4 @@ +using System.Diagnostics; + +namespace GitAnchor.Actions; +delegate Task CallableAction(); diff --git a/repo-backup-util/Actions/Create.cs b/git-anchor/Actions/Create.cs similarity index 100% rename from repo-backup-util/Actions/Create.cs rename to git-anchor/Actions/Create.cs diff --git a/repo-backup-util/Actions/Help.cs b/git-anchor/Actions/Help.cs similarity index 91% rename from repo-backup-util/Actions/Help.cs rename to git-anchor/Actions/Help.cs index 70c68cd..f9b59cd 100644 --- a/repo-backup-util/Actions/Help.cs +++ b/git-anchor/Actions/Help.cs @@ -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 ]"); Console.WriteLine(" Finds an existing backup matching the provided pattern."); Console.WriteLine(" --regex, -e Find your backup directory based on a Regex search."); diff --git a/git-anchor/Actions/List.cs b/git-anchor/Actions/List.cs new file mode 100644 index 0000000..b217803 --- /dev/null +++ b/git-anchor/Actions/List.cs @@ -0,0 +1,11 @@ +using System.Diagnostics; + +namespace GitAnchor.Actions; +class List : BaseAction +{ + static async new Task Run() + { + return ActivityStatusCode.Ok; + } + +} diff --git a/repo-backup-util/Actions/Pull.cs b/git-anchor/Actions/Pull.cs similarity index 100% rename from repo-backup-util/Actions/Pull.cs rename to git-anchor/Actions/Pull.cs diff --git a/repo-backup-util/lib/CommandLine.cs b/git-anchor/Lib/CommandLine.cs similarity index 100% rename from repo-backup-util/lib/CommandLine.cs rename to git-anchor/Lib/CommandLine.cs diff --git a/repo-backup-util/lib/FileSystem.cs b/git-anchor/Lib/FileSystem.cs similarity index 100% rename from repo-backup-util/lib/FileSystem.cs rename to git-anchor/Lib/FileSystem.cs diff --git a/repo-backup-util/lib/GitHub.cs b/git-anchor/Lib/GitHub.cs similarity index 100% rename from repo-backup-util/lib/GitHub.cs rename to git-anchor/Lib/GitHub.cs diff --git a/repo-backup-util/lib/Volumes.cs b/git-anchor/Lib/Volumes.cs similarity index 100% rename from repo-backup-util/lib/Volumes.cs rename to git-anchor/Lib/Volumes.cs diff --git a/git-anchor/Program.cs b/git-anchor/Program.cs new file mode 100644 index 0000000..b7b22d0 --- /dev/null +++ b/git-anchor/Program.cs @@ -0,0 +1,31 @@ +using System.Diagnostics; +using GitAnchor.Actions; + +string[] inputArgs = Environment.GetCommandLineArgs(); + +SortedDictionary 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; +} diff --git a/repo-backup-util/git-anchor.csproj b/git-anchor/git-anchor.csproj similarity index 100% rename from repo-backup-util/git-anchor.csproj rename to git-anchor/git-anchor.csproj diff --git a/repo-backup-util/Program.cs b/repo-backup-util/Program.cs deleted file mode 100644 index b19733e..0000000 --- a/repo-backup-util/Program.cs +++ /dev/null @@ -1 +0,0 @@ -await GitAnchor.Lib.EntryPoint.Run(); diff --git a/repo-backup-util/lib/Entrypoint.cs b/repo-backup-util/lib/Entrypoint.cs deleted file mode 100644 index 48bb2d5..0000000 --- a/repo-backup-util/lib/Entrypoint.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections; -using System.Diagnostics; -using GitAnchor.Actions; - -namespace GitAnchor.Lib; - -public class EntryPoint -{ - public static async Task Run() - { - string[] args = Environment.GetCommandLineArgs(); - - SortedDictionary> options = new() - { - { "create", Create.Run() }, - { "pull", Pull.Run() }, - { "help", Help.Run() } - }; - - try - { - foreach (string arg in args) - { - var result = options.TryGetValue(arg, out Task? action); - - if (!result) continue; - if (action != null) return await action; - } - - return await Help.Run(); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - return ActivityStatusCode.Error; - } - } -}