diff --git a/.editorconfig b/.editorconfig index 9270fbad..5b46bd60 100644 --- a/.editorconfig +++ b/.editorconfig @@ -121,4 +121,67 @@ csharp_preserve_single_line_blocks = true # CS4014: Task not awaited dotnet_diagnostic.CS4014.severity = error # CS1998: Async function does not contain await -dotnet_diagnostic.CS1998.severity = silent \ No newline at end of file +dotnet_diagnostic.CS1998.severity = silent + +############################### +# C# Nullability # +############################### +# CS8602: Dereference of a possibly null reference. +dotnet_diagnostic.CS8602.severity = error + +# CS8600: Converting null literal or possible null value to non-nullable type. +dotnet_diagnostic.CS8600.severity = error + +# CS8619: Nullability of reference types in value doesn't match target type. +dotnet_diagnostic.CS8619.severity = error + +# CS8603: Possible null reference return. +dotnet_diagnostic.CS8603.severity = error + +# CS8625: Cannot convert null literal to non-nullable reference type. +dotnet_diagnostic.CS8625.severity = error + +# CS8653: A default expression introduces a null value for a type parameter. +dotnet_diagnostic.CS8653.severity = silent + +# CS8601: Possible null reference assignment. +dotnet_diagnostic.CS8601.severity = error + +# CS8604: Possible null reference argument. +dotnet_diagnostic.CS8604.severity = error + +# CS8622: Nullability of reference types in type of parameter doesn't match the target delegate. +dotnet_diagnostic.CS8622.severity = error + +# CS8610: Nullability of reference types in type of parameter doesn't match overridden member. +dotnet_diagnostic.CS8610.severity = error + +# CS8618: Non-nullable field is uninitialized. Consider declaring as nullable. +dotnet_diagnostic.CS8618.severity = error + +# CS8629: Nullable value type may be null. +dotnet_diagnostic.CS8629.severity = error + +# CS8620: Argument cannot be used for parameter due to differences in the nullability of reference types. +dotnet_diagnostic.CS8620.severity = error + +# CS8614: Nullability of reference types in type of parameter doesn't match implicitly implemented member. +dotnet_diagnostic.CS8614.severity = error + +# CS8617: Nullability of reference types in type of parameter doesn't match implemented member. +dotnet_diagnostic.CS8617.severity = error + +# CS8611: Nullability of reference types in type of parameter doesn't match partial method declaration. +dotnet_diagnostic.CS8611.severity = error + +# CS8597: Thrown value may be null. +dotnet_diagnostic.CS8597.severity = error + +# CS8609: Nullability of reference types in return type doesn't match overridden member. +dotnet_diagnostic.CS8609.severity = error + +# CS8714: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint. +dotnet_diagnostic.CS8714.severity = error + +# CS8605: Unboxing a possibly null value. +dotnet_diagnostic.CS8605.severity = error \ No newline at end of file diff --git a/Wabbajack.CLI/CLIUtils.cs b/Wabbajack.CLI/CLIUtils.cs index c9a081e8..8f20180e 100644 --- a/Wabbajack.CLI/CLIUtils.cs +++ b/Wabbajack.CLI/CLIUtils.cs @@ -1,9 +1,21 @@ using System; +using Wabbajack.CLI.Verbs; namespace Wabbajack.CLI { + [AttributeUsage(AttributeTargets.Property)] + internal class FileAttribute : Attribute { } + + [AttributeUsage(AttributeTargets.Property)] + internal class DirectoryAttribute : Attribute { } + internal static class CLIUtils { + internal static bool VerifyArguments(AVerb verb) + { + return true; + } + internal static void Log(string msg, bool newLine = true) { //TODO: maybe also write to a log file? diff --git a/Wabbajack.CLI/Verbs/AVerb.cs b/Wabbajack.CLI/Verbs/AVerb.cs index 5d341f0a..5693a520 100644 --- a/Wabbajack.CLI/Verbs/AVerb.cs +++ b/Wabbajack.CLI/Verbs/AVerb.cs @@ -1,6 +1,4 @@ -using System.Text; -using System.Threading; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Wabbajack.CLI.Verbs { diff --git a/Wabbajack.CLI/Verbs/ChangeDownload.cs b/Wabbajack.CLI/Verbs/ChangeDownload.cs index 966dfad9..f974d308 100644 --- a/Wabbajack.CLI/Verbs/ChangeDownload.cs +++ b/Wabbajack.CLI/Verbs/ChangeDownload.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Text; @@ -18,16 +19,16 @@ namespace Wabbajack.CLI.Verbs public class ChangeDownload : AVerb { [Option("input", Required = true, HelpText = "Input folder containing the downloads you want to move")] - public string Input { get; set; } + public string? Input { get; set; } [Option("output", Required = true, HelpText = "Output folder the downloads should be transferred to")] - public string Output { get; set; } + public string? Output { get; set; } [Option("modlist", Required = true, HelpText = "The Modlist, can either be a .wabbajack or a modlist.txt file")] - public string Modlist { get; set; } + public string? Modlist { get; set; } [Option("mods", Required = false, HelpText = "Mods folder location if the provided modlist file is an MO2 modlist.txt")] - public string Mods { get; set; } + public string? Mods { get; set; } [Option("copy", Default = true, HelpText = "Whether to copy the files", SetName = "copy")] public bool Copy { get; set; } @@ -69,13 +70,13 @@ namespace Wabbajack.CLI.Verbs Directory.CreateDirectory(Output); } - if (!Modlist.EndsWith(Consts.ModListExtension) && !Modlist.EndsWith("modlist.txt")) + if (Modlist != null && (!Modlist.EndsWith(Consts.ModListExtension) && !Modlist.EndsWith("modlist.txt"))) return CLIUtils.Exit($"The file {Modlist} is not a valid modlist file!", -1); if (Copy && Move) return CLIUtils.Exit("You can't set both copy and move flags!", -1); - var isModlist = Modlist.EndsWith(Consts.ModListExtension); + var isModlist = Modlist != null && Modlist.EndsWith(Consts.ModListExtension); var list = new List(); diff --git a/Wabbajack.CLI/Verbs/Changelog.cs b/Wabbajack.CLI/Verbs/Changelog.cs new file mode 100644 index 00000000..794e92ee --- /dev/null +++ b/Wabbajack.CLI/Verbs/Changelog.cs @@ -0,0 +1,24 @@ +using System; +using System.Threading.Tasks; +using CommandLine; + +namespace Wabbajack.CLI.Verbs +{ + [Verb("changelog", HelpText = "Generate a changelog using two different versions of the same Modlist.")] + public class Changelog : AVerb + { + [Option("original", Required = true, HelpText = "The original/previous modlist")] + public string? Original { get; set; } + + [Option("update", Required = true, HelpText = "The current/updated modlist")] + public string? Update { get; set; } + + [Option('o', "output", Required = false, HelpText = "The output file")] + public string? Output { get; set; } + + protected override Task Run() + { + throw new NotImplementedException(); + } + } +} diff --git a/Wabbajack.CLI/Verbs/Decrypt.cs b/Wabbajack.CLI/Verbs/Decrypt.cs index d0d0126d..388207d0 100644 --- a/Wabbajack.CLI/Verbs/Decrypt.cs +++ b/Wabbajack.CLI/Verbs/Decrypt.cs @@ -9,11 +9,11 @@ namespace Wabbajack.CLI.Verbs public class Decrypt : AVerb { [Option('n', "name", Required = true, HelpText = @"Credential to encrypt and store in AppData\Local\Wabbajack")] - public string Name { get; set; } + public string? Name { get; set; } [Option('o', "output", Required = true, HelpText = @"Output file for the decrypted data")] - public string Output { get; set; } + public string? Output { get; set; } protected override async Task Run() { diff --git a/Wabbajack.CLI/Verbs/DeleteFile.cs b/Wabbajack.CLI/Verbs/DeleteFile.cs index c89b698a..124e9f94 100644 --- a/Wabbajack.CLI/Verbs/DeleteFile.cs +++ b/Wabbajack.CLI/Verbs/DeleteFile.cs @@ -9,7 +9,8 @@ namespace Wabbajack.CLI.Verbs public class DeleteFile : AVerb { [Option('n', "name", Required = true, HelpText = @"Full name (as returned by my-files) of the file")] - public string Name { get; set; } + public string? Name { get; set; } + protected override async Task Run() { Console.WriteLine(await AuthorAPI.DeleteFile(Name)); diff --git a/Wabbajack.CLI/Verbs/DownloadUrl.cs b/Wabbajack.CLI/Verbs/DownloadUrl.cs index 3a957fd2..f29ef59a 100644 --- a/Wabbajack.CLI/Verbs/DownloadUrl.cs +++ b/Wabbajack.CLI/Verbs/DownloadUrl.cs @@ -14,10 +14,10 @@ namespace Wabbajack.CLI.Verbs public class DownloadUrl : AVerb { [Option('u', "url", Required = true, HelpText = "Url to download")] - public Uri Url { get; set; } + public Uri? Url { get; set; } [Option('o', "output", Required = true, HelpText = "Output file name")] - public string Output { get; set; } + public string? Output { get; set; } protected override async Task Run() { diff --git a/Wabbajack.CLI/Verbs/Encrypt.cs b/Wabbajack.CLI/Verbs/Encrypt.cs index ace41e2a..9213349f 100644 --- a/Wabbajack.CLI/Verbs/Encrypt.cs +++ b/Wabbajack.CLI/Verbs/Encrypt.cs @@ -9,10 +9,10 @@ namespace Wabbajack.CLI.Verbs public class Encrypt : AVerb { [Option('n', "name", Required = true, HelpText = @"Credential to encrypt and store in AppData\Local\Wabbajack")] - public string Name { get; set; } + public string? Name { get; set; } [Option('i', "input", Required = true, HelpText = @"Source data file name")] - public string Input { get; set; } + public string? Input { get; set; } protected override async Task Run() { diff --git a/Wabbajack.CLI/Verbs/Validate.cs b/Wabbajack.CLI/Verbs/Validate.cs index 5a21e0af..141c9464 100644 --- a/Wabbajack.CLI/Verbs/Validate.cs +++ b/Wabbajack.CLI/Verbs/Validate.cs @@ -1,11 +1,9 @@ using System; -using System.Reactive.Linq; using System.Threading.Tasks; using CommandLine; using Wabbajack.Common; using Wabbajack.Lib; using Wabbajack.Lib.Validation; -using Wabbajack.VirtualFileSystem; using File = Alphaleonis.Win32.Filesystem.File; namespace Wabbajack.CLI.Verbs @@ -14,12 +12,11 @@ namespace Wabbajack.CLI.Verbs public class Validate : AVerb { [Option('i', "input", Required = true, HelpText = @"Modlist file")] - public string Input { get; set; } + public string? Input { get; set; } /// /// Runs the Validation of a Modlist /// - /// /// /// /// -1 bad Input @@ -33,7 +30,7 @@ namespace Wabbajack.CLI.Verbs return CLIUtils.Exit($"The file {Input} does not exist!", -1); - if (!Input.EndsWith(Consts.ModListExtension)) + if (Input != null && !Input.EndsWith(Consts.ModListExtension)) return CLIUtils.Exit($"The file {Input} does not end with {Consts.ModListExtension}!", -1); ModList modlist; diff --git a/Wabbajack.CLI/Wabbajack.CLI.csproj b/Wabbajack.CLI/Wabbajack.CLI.csproj index 177a680f..ed51c614 100644 --- a/Wabbajack.CLI/Wabbajack.CLI.csproj +++ b/Wabbajack.CLI/Wabbajack.CLI.csproj @@ -12,6 +12,8 @@ An automated ModList installer true win10-x64 + 8.0 + enable