Skip to content

Commit

Permalink
Updated source
Browse files Browse the repository at this point in the history
  • Loading branch information
Iswenzz committed Sep 24, 2024
1 parent c247ac7 commit 9257d6e
Show file tree
Hide file tree
Showing 13 changed files with 396 additions and 415 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
dotnet-version: '9.0.x'

- name: Build
run: |
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
obj/
.vs/
bin/
obj/
*.sh
42 changes: 21 additions & 21 deletions GitTools.csproj
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>
68 changes: 34 additions & 34 deletions GitTools/CLI/CLIParser.cs
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();
}
}
13 changes: 7 additions & 6 deletions GitTools/CLI/CopyCommits.cs
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
{
Expand Down Expand Up @@ -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>
Expand Down
20 changes: 10 additions & 10 deletions GitTools/CLI/ICMD.cs
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();
}
}
114 changes: 58 additions & 56 deletions GitTools/CLI/MockCommit.cs
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));
}
}
}
20 changes: 10 additions & 10 deletions GitTools/CLI/Options.cs
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() { }
}
}
25 changes: 25 additions & 0 deletions GitTools/GitTools.sln
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
Loading

0 comments on commit 9257d6e

Please sign in to comment.