From 3dc178c6831ee54acde0c3386dcbe0d3c34178f5 Mon Sep 17 00:00:00 2001 From: azures04 Date: Tue, 27 Jan 2026 02:02:49 +0100 Subject: [PATCH] Add CLI entry point and update packaging metadata Introduces a new Cli.cs file providing a command-line interface for packing and unpacking with AzuresPackager. Updates project metadata in AzuresPackager.csproj, including package version, output type, and dependency version bump for SharpCompress. Also updates publish.ps1 to use the new version and skip duplicate package uploads. --- AzuresPackager.csproj | 13 ++++++---- Cli.cs | 55 +++++++++++++++++++++++++++++++++++++++++++ Packager.cs | 6 +---- publish.ps1 | 4 ++-- 4 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 Cli.cs diff --git a/AzuresPackager.csproj b/AzuresPackager.csproj index 4716585..916fbff 100644 --- a/AzuresPackager.csproj +++ b/AzuresPackager.csproj @@ -1,16 +1,19 @@  + Exe net8.0 enable enable + true - ./nupkg - azures04 - https://gitea.azures.fr/azures04/AzuresPackager - git + AzuresPackager + 0.0.2 + Azures04 + + false - + \ No newline at end of file diff --git a/Cli.cs b/Cli.cs new file mode 100644 index 0000000..4971a12 --- /dev/null +++ b/Cli.cs @@ -0,0 +1,55 @@ +namespace AzuresPackager.Cli; + +public class Program { + public static void Main(string[] args) { + var arguments = new Dictionary(); + + for (int i = 0; i < args.Length; i++) { + if (args[i].StartsWith("--") && i + 1 < args.Length) { + arguments[args[i].ToLower()] = args[i + 1]; + i++; + } + } + + if (arguments.ContainsKey("--action") || !arguments.ContainsKey("--sourcedir") || !arguments.ContainsKey("--outputpath") || !arguments.ContainsKey("--key")) { + Console.WriteLine("Usage: AzuresPackager.Cli --action <[pack/unpack]> --sourceDir --outputPath --key "); + return; + } + + string source = arguments["--sourcedir"]; + string output = arguments["--outputpath"]; + + if (!byte.TryParse(arguments["--key"], out byte key)) { + Console.WriteLine("Erreur : La clé XOR (--key) doit être un nombre entre 0 et 255."); + return; + } + + switch (arguments["--action"]) { + case "pack": + try { + Console.WriteLine($"[AzuresPackager] Packaging : {source} -> {output} (Key: {key})"); + Packager.Pack(source, output, key); + Console.WriteLine("[AzuresPackager] Success"); + Environment.Exit(0); + } catch (Exception ex) { + Console.WriteLine($"[AzuresPackager] Erreur : {ex.Message}"); + Environment.Exit(1); + } + break; + case "unpack": + try { + Console.WriteLine($"[AzuresPackager] Unpackaging : {source} -> {output} (Key: {key})"); + AzuresPackage azp = new AzuresPackage(source, key); + azp.Unpack(output); + Console.WriteLine("[AzuresPackager] Success"); + Environment.Exit(0); + } catch (Exception ex) { + Console.WriteLine($"[AzuresPackager] Erreur : {ex.Message}"); + Environment.Exit(1); + } + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/Packager.cs b/Packager.cs index 02fa6f9..3a965c7 100644 --- a/Packager.cs +++ b/Packager.cs @@ -1,11 +1,7 @@ -using System.IO; -using System.Text; +using System.Text; using SharpCompress.Archives; using SharpCompress.Common; using SharpCompress.Writers; -using System.Collections.Generic; -using System.Linq; -using System; namespace AzuresPackager; diff --git a/publish.ps1 b/publish.ps1 index 7aa90c2..5a323b4 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -1,5 +1,5 @@ clear -$version = "0.0.1" +$version = "0.0.2" Write-Host "`r`n[Task 1/4] Cleaning project..." -ForegroundColor Magenta dotnet clean @@ -14,4 +14,4 @@ Write-Host "`r`n[Task 4/4] Packing project..." -ForegroundColor Magenta dotnet pack --version $version Write-Host "`r`n[Task 5/4] Publishing project..." -ForegroundColor Magenta -dotnet nuget push --source AzuresGitea "nupkg\AzuresPackager.$version.nupkg" \ No newline at end of file +dotnet nuget push --source AzuresGitea "nupkg\AzuresPackager.$version.nupkg" --skip-duplicate \ No newline at end of file