This commit is contained in:
ProfessionalUwU 2023-06-05 00:32:48 +02:00
commit 6f295b0e06
Signed by: ProfessionalUwU
GPG Key ID: 013AD77C0A9DD3F2
4 changed files with 66 additions and 18 deletions

26
.editorconfig Normal file
View File

@ -0,0 +1,26 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
# Indentation and spacing
indent_size = 4
indent_style = space
tab_width = 4
# Naming Conventions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# New line preferences
csharp_new_line_before_open_brace = none
csharp_new_line_before_else = false
csharp_new_line_before_catch = false
csharp_new_line_before_finally = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
# Switch case
csharp_indent_case_contents = true

View File

@ -1,15 +1,19 @@
public class Program {
static void Main(string[] args) {
if (args.Length == 0) {
Console.ForegroundColor = ConsoleColor.Red;
if (args.Length == 0) {
Console.WriteLine("Please specify an option.");
Console.ResetColor();
Console.WriteLine("Options are: checksum, countmd5, deletemd5, compareChecksums");
} else {
PrintAvailableOptions();
return;
} else if (args.Length > 1) {
Console.WriteLine("Too many options.");
return;
}
Console.ForegroundColor = ConsoleColor.Green;
switch (args[0]) {
case "checksum":
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Starting the checksum process.");
Console.ResetColor();
@ -17,10 +21,8 @@
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Checksum process finished");
Console.ResetColor();
break;
case "countmd5":
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Counting md5 checksum files.");
Console.ResetColor();
@ -28,10 +30,8 @@
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Finished counting all md5 checksum files.");
Console.ResetColor();
break;
case "deletemd5":
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Deleting all md5 checksum files.");
Console.ResetColor();
@ -39,15 +39,38 @@
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Deleted all md5 checksum files.");
Console.ResetColor();
break;
case "compareChecksums":
Console.WriteLine("Comparing all md5 checksum files. If there is none, creating one.");
Console.ResetColor();
Chksum.compareChecksums();
break;
case "help":
PrintAvailableOptions();
break;
default:
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Invalid option. Maybe you mistyped it?");
PrintAvailableOptions();
break;
}
}
static void PrintAvailableOptions() {
String[] options = {
"checksum",
"countmd5",
"deletemd5",
"compareChecksums",
"help"
};
Console.ResetColor();
Console.WriteLine("usage: chksum [option]");
Console.WriteLine("Here is a list of all available options:");
foreach (String option in options) {
Console.WriteLine("\t" + option);
}
}
}

View File

@ -20,10 +20,8 @@ public class Chksum {
// }
private static string CalculateMD5(string filename) {
using (var md5 = System.Security.Cryptography.MD5.Create())
{
using (var stream = File.OpenRead(filename))
{
using (var md5 = System.Security.Cryptography.MD5.Create()) {
using (var stream = File.OpenRead(filename)) {
var hash = md5.ComputeHash(stream);
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
}
@ -110,5 +108,4 @@ public class Chksum {
compareChecksums();
}
}
}

2
justfile Normal file
View File

@ -0,0 +1,2 @@
publish:
@dotnet publish --configuration Release chksum.csproj