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.
55 lines
2.2 KiB
C#
55 lines
2.2 KiB
C#
namespace AzuresPackager.Cli;
|
|
|
|
public class Program {
|
|
public static void Main(string[] args) {
|
|
var arguments = new Dictionary<string, string>();
|
|
|
|
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 <path> --outputPath <path> --key <byte>");
|
|
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;
|
|
}
|
|
}
|
|
} |