-
-
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.
- Loading branch information
Showing
13 changed files
with
396 additions
and
415 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
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,3 +1,4 @@ | ||
bin/ | ||
obj/ | ||
.vs/ | ||
bin/ | ||
obj/ | ||
*.sh |
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,21 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0-windows</TargetFramework> | ||
<Authors>Iswenzz</Authors> | ||
<Company /> | ||
<Copyright>Iswenzz (c) 2021</Copyright> | ||
<PackageProjectUrl>https://iswenzz.com/</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/Iswenzz/GitTools.git</RepositoryUrl> | ||
<RootNamespace>Iswenzz</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CommandLineParser" Version="2.9.1" /> | ||
<PackageReference Include="LibGit2Sharp" Version="0.27.2" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageReference Include="Ookii.Dialogs.WinForms" Version="4.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0-windows7.0</TargetFramework> | ||
<Authors>Iswenzz</Authors> | ||
<Company /> | ||
<Copyright>Iswenzz (c) 2021</Copyright> | ||
<PackageProjectUrl>https://iswenzz.com/</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/Iswenzz/GitTools.git</RepositoryUrl> | ||
<RootNamespace>Iswenzz</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CommandLineParser" Version="2.9.1" /> | ||
<PackageReference Include="LibGit2Sharp" Version="0.30.0" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageReference Include="Ookii.Dialogs.WinForms" Version="4.0.0" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
using CommandLine; | ||
|
||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// Class for parsing the program arguments. | ||
/// </summary> | ||
public static class CLIParser | ||
{ | ||
public static Options Options { get; set; } | ||
public static CopyCommits CopyCommits { get; set; } | ||
public static MockCommit Commit { get; set; } | ||
|
||
/// <summary> | ||
/// Parse the program arguments. | ||
/// </summary> | ||
/// <param name="args">The program arguments.</param> | ||
public static void Parse(string[] args) | ||
{ | ||
Parser.Default.ParseArguments<Options, CopyCommits, MockCommit>(args) | ||
.WithParsed<Options>(options => ParseAndExecute(Options = options)) | ||
.WithParsed<CopyCommits>(options => ParseAndExecute(CopyCommits = options)) | ||
.WithParsed<MockCommit>(options => ParseAndExecute(Commit = options)); | ||
} | ||
|
||
/// <summary> | ||
/// Parse the arguments using the CommandLineParser library. | ||
/// </summary> | ||
/// <typeparam name="T">Class that implements ICommand interface.</typeparam> | ||
/// <param name="options">The parsed options.</param> | ||
private static void ParseAndExecute<T>(T options) where T : ICMD => | ||
options.Execute(); | ||
} | ||
} | ||
using CommandLine; | ||
|
||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// Class for parsing the program arguments. | ||
/// </summary> | ||
public static class CLIParser | ||
{ | ||
public static Options Options { get; set; } | ||
public static CopyCommits CopyCommits { get; set; } | ||
public static MockCommit Commit { get; set; } | ||
|
||
/// <summary> | ||
/// Parse the program arguments. | ||
/// </summary> | ||
/// <param name="args">The program arguments.</param> | ||
public static void Parse(string[] args) | ||
{ | ||
Parser.Default.ParseArguments<Options, CopyCommits, MockCommit>(args) | ||
.WithParsed<Options>(options => ParseAndExecute(Options = options)) | ||
.WithParsed<CopyCommits>(options => ParseAndExecute(CopyCommits = options)) | ||
.WithParsed<MockCommit>(options => ParseAndExecute(Commit = options)); | ||
} | ||
|
||
/// <summary> | ||
/// Parse the arguments using the CommandLineParser library. | ||
/// </summary> | ||
/// <typeparam name="T">Class that implements ICommand interface.</typeparam> | ||
/// <param name="options">The parsed options.</param> | ||
private static void ParseAndExecute<T>(T options) where T : ICMD => | ||
options.Execute(); | ||
} | ||
} |
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,14 +1,14 @@ | ||
using System; | ||
using System.IO; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
|
||
using CommandLine; | ||
using CommandLine.Text; | ||
using LibGit2Sharp; | ||
|
||
using Iswenzz.GitTools.Sys; | ||
using Iswenzz.GitTools.Utils; | ||
using System.IO; | ||
|
||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
|
@@ -45,17 +45,18 @@ public class CopyCommits : ICMD | |
[Usage(ApplicationAlias = "gittools")] | ||
public static IEnumerable<Example> Examples | ||
{ | ||
get => new List<Example> { | ||
new Example("Copy the commits on a specific date", | ||
new CopyCommits { | ||
get => [ | ||
new("Copy the commits on a specific date", | ||
new CopyCommits | ||
{ | ||
User = "Iswenzz", | ||
Email = "[email protected]", | ||
InputRepository = "C:\\Repository\\A", | ||
OutputRepository = "C:\\Repository\\B", | ||
SinceDate = "25/06/1999", | ||
UntilDate = "04/07/2021" | ||
}) | ||
}; | ||
]; | ||
} | ||
|
||
/// <summary> | ||
|
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,10 +1,10 @@ | ||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// Executable command interface. | ||
/// </summary> | ||
public interface ICMD | ||
{ | ||
public void Execute(); | ||
} | ||
} | ||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// Executable command interface. | ||
/// </summary> | ||
public interface ICMD | ||
{ | ||
public void Execute(); | ||
} | ||
} |
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,56 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using CommandLine; | ||
using CommandLine.Text; | ||
|
||
using Iswenzz.GitTools.Sys; | ||
|
||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// Command to create a commit at a specific date. | ||
/// </summary> | ||
[Verb("commit", HelpText = "Create a commit at a specific date.")] | ||
public class MockCommit : ICMD | ||
{ | ||
[Option('u', "user", Required = true, HelpText = "The user.")] | ||
public string User { get; set; } | ||
|
||
[Option('e', "email", Required = true, HelpText = "The email.")] | ||
public string Email { get; set; } | ||
|
||
[Option('m', "message", Required = true, HelpText = "The commit message.")] | ||
public string Message { get; set; } | ||
|
||
[Option('o', "output-repository", Required = true, HelpText = "The output repository path.")] | ||
public string OutputRepository { get; set; } | ||
|
||
[Option('d', "date", HelpText = "Commit at a specific date.")] | ||
public string Date { get; set; } = DateTime.Now.ToString("O"); | ||
|
||
[Usage(ApplicationAlias = "gittools")] | ||
public static IEnumerable<Example> Examples | ||
{ | ||
get => new List<Example> { | ||
new Example("Create a commit at a specific date", | ||
new MockCommit { | ||
User = "Iswenzz", | ||
Email = "[email protected]", | ||
OutputRepository = "C:\\Repository", | ||
Message = "Happy Birthday !", | ||
Date = "25/06/2021" | ||
}) | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Execute the command. | ||
/// </summary> | ||
public void Execute() | ||
{ | ||
// Commits to output repository | ||
Git git = new(User, Email, OutputRepository); | ||
git.MockCommit(Message, DateTime.Parse(Date)); | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using CommandLine; | ||
using CommandLine.Text; | ||
|
||
using Iswenzz.GitTools.Sys; | ||
|
||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// Command to create a commit at a specific date. | ||
/// </summary> | ||
[Verb("commit", HelpText = "Create a commit at a specific date.")] | ||
public class MockCommit : ICMD | ||
{ | ||
[Option('u', "user", Required = true, HelpText = "The user.")] | ||
public string User { get; set; } | ||
|
||
[Option('e', "email", Required = true, HelpText = "The email.")] | ||
public string Email { get; set; } | ||
|
||
[Option('m', "message", Required = true, HelpText = "The commit message.")] | ||
public string Message { get; set; } | ||
|
||
[Option('o', "output-repository", Required = true, HelpText = "The output repository path.")] | ||
public string OutputRepository { get; set; } | ||
|
||
[Option('d', "date", HelpText = "Commit at a specific date.")] | ||
public string Date { get; set; } = DateTime.Now.ToString("O"); | ||
|
||
[Usage(ApplicationAlias = "gittools")] | ||
public static IEnumerable<Example> Examples | ||
{ | ||
get => [ | ||
new("Create a commit at a specific date", | ||
new MockCommit | ||
{ | ||
User = "Iswenzz", | ||
Email = "[email protected]", | ||
OutputRepository = "C:\\Repository", | ||
Message = "Happy Birthday !", | ||
Date = "25/06/2021" | ||
}) | ||
]; | ||
} | ||
|
||
/// <summary> | ||
/// Execute the command. | ||
/// </summary> | ||
public void Execute() | ||
{ | ||
// Commits to output repository | ||
Git git = new(User, Email, OutputRepository); | ||
git.MockCommit(Message, DateTime.Parse(Date)); | ||
} | ||
} | ||
} |
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,10 +1,10 @@ | ||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// The program default CLI. | ||
/// </summary> | ||
public class Options : ICMD | ||
{ | ||
public void Execute() { } | ||
} | ||
} | ||
namespace Iswenzz.GitTools.CLI | ||
{ | ||
/// <summary> | ||
/// The program default CLI. | ||
/// </summary> | ||
public class Options : ICMD | ||
{ | ||
public void Execute() { } | ||
} | ||
} |
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35309.182 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools", "..\GitTools.csproj", "{9DEDF5CE-AF1A-4AF9-9894-8F825B0FB411}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9DEDF5CE-AF1A-4AF9-9894-8F825B0FB411}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9DEDF5CE-AF1A-4AF9-9894-8F825B0FB411}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9DEDF5CE-AF1A-4AF9-9894-8F825B0FB411}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9DEDF5CE-AF1A-4AF9-9894-8F825B0FB411}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A40B826F-D647-4A51-B92F-856ACDE66C0B} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.