diff --git a/PiwigoDirectorySync/Commands/DownloadImagesCommand.cs b/PiwigoDirectorySync/Commands/DownloadImagesCommand.cs index d1d9847..9ab9b04 100644 --- a/PiwigoDirectorySync/Commands/DownloadImagesCommand.cs +++ b/PiwigoDirectorySync/Commands/DownloadImagesCommand.cs @@ -6,7 +6,7 @@ using Spectre.Console.Cli; namespace PiwigoDirectorySync.Commands; -internal class DownloadImagesCommand : CancellableAsyncCommand +internal class DownloadImagesCommand : CancellableAsyncCommand { private readonly IImageSynchronizer _imageSynchronizer; private readonly ILogger _logger; @@ -30,4 +30,8 @@ internal class DownloadImagesCommand : CancellableAsyncCommand +internal class PiwigoAddCommand : CancellableAsyncCommand { private readonly ILogger _logger; private readonly PersistenceContext _persistenceContext; @@ -49,4 +49,56 @@ internal class PiwigoAddCommand : CancellableAsyncCommand return 0; } + + internal class PiwigoAddSettings : CommandSettings + { + [CommandArgument(0, "")] public string ServerName { get; init; } = string.Empty; + [CommandArgument(1, "")] public string UserName { get; init; } = string.Empty; + [CommandArgument(1, "")] public string Password { get; init; } = string.Empty; + [CommandArgument(1, "")] public string Url { get; init; } = string.Empty; + + [CommandArgument(1, "")] + public string RootDirectory { get; init; } = string.Empty; + + public override ValidationResult Validate() + { + var baseResult = base.Validate(); + if (!baseResult.Successful) + { + return baseResult; + } + + if (string.IsNullOrWhiteSpace(ServerName)) + { + return ValidationResult.Error("Please specify a server name"); + } + + if (string.IsNullOrWhiteSpace(Url)) + { + return ValidationResult.Error("Please specify a server url"); + } + + if (string.IsNullOrWhiteSpace(UserName)) + { + return ValidationResult.Error("Please specify a valid username for the server"); + } + + if (string.IsNullOrWhiteSpace(Password)) + { + return ValidationResult.Error("Please specify a password"); + } + + if (string.IsNullOrWhiteSpace(RootDirectory)) + { + return ValidationResult.Error("Please specify a root directory"); + } + + if (!Directory.Exists(RootDirectory)) + { + return ValidationResult.Error($"The root directory {RootDirectory} does not exist or is not accessible"); + } + + return ValidationResult.Success(); + } + } } \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/PiwigoAddSettings.cs b/PiwigoDirectorySync/Commands/PiwigoAddSettings.cs deleted file mode 100644 index d56227c..0000000 --- a/PiwigoDirectorySync/Commands/PiwigoAddSettings.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Spectre.Console; -using Spectre.Console.Cli; - -namespace PiwigoDirectorySync.Commands; - -internal class PiwigoAddSettings : CommandSettings -{ - [CommandArgument(0, "")] public string ServerName { get; init; } = string.Empty; - [CommandArgument(1, "")] public string UserName { get; init; } = string.Empty; - [CommandArgument(1, "")] public string Password { get; init; } = string.Empty; - [CommandArgument(1, "")] public string Url { get; init; } = string.Empty; - - [CommandArgument(1, "")] - public string RootDirectory { get; init; } = string.Empty; - - public override ValidationResult Validate() - { - var baseResult = base.Validate(); - if (!baseResult.Successful) - { - return baseResult; - } - - if (string.IsNullOrWhiteSpace(ServerName)) - { - return ValidationResult.Error("Please specify a server name"); - } - - if (string.IsNullOrWhiteSpace(Url)) - { - return ValidationResult.Error("Please specify a server url"); - } - - if (string.IsNullOrWhiteSpace(UserName)) - { - return ValidationResult.Error("Please specify a valid username for the server"); - } - - if (string.IsNullOrWhiteSpace(Password)) - { - return ValidationResult.Error("Please specify a password"); - } - - if (string.IsNullOrWhiteSpace(RootDirectory)) - { - return ValidationResult.Error("Please specify a root directory"); - } - - if (!Directory.Exists(RootDirectory)) - { - return ValidationResult.Error($"The root directory {RootDirectory} does not exist or is not accessible"); - } - - return ValidationResult.Success(); - } -} \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/PiwigoListCommand.cs b/PiwigoDirectorySync/Commands/PiwigoListCommand.cs index df7030b..3a29fce 100644 --- a/PiwigoDirectorySync/Commands/PiwigoListCommand.cs +++ b/PiwigoDirectorySync/Commands/PiwigoListCommand.cs @@ -7,7 +7,7 @@ using Spectre.Console.Cli; namespace PiwigoDirectorySync.Commands; -internal class PiwigoListCommand : CancellableAsyncCommand +internal class PiwigoListCommand : CancellableAsyncCommand { private readonly ILogger _logger; private readonly PersistenceContext _persistenceContext; @@ -21,7 +21,7 @@ internal class PiwigoListCommand : CancellableAsyncCommand protected override async Task ExecuteAsync(CommandContext context, PiwigoListSettings settings, CancellationToken cancellation) { var piwigoServers = await _persistenceContext.PiwigoServers.ToListAsync(cancellation); - + PrintServers(piwigoServers); return 0; @@ -42,4 +42,8 @@ internal class PiwigoListCommand : CancellableAsyncCommand AnsiConsole.Write(table); } + + internal class PiwigoListSettings : CommandSettings + { + } } \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/PiwigoListSettings.cs b/PiwigoDirectorySync/Commands/PiwigoListSettings.cs deleted file mode 100644 index fd4af71..0000000 --- a/PiwigoDirectorySync/Commands/PiwigoListSettings.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Spectre.Console.Cli; - -namespace PiwigoDirectorySync.Commands; - -internal class PiwigoListSettings : CommandSettings -{ -} \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/ScanCommand.cs b/PiwigoDirectorySync/Commands/ScanCommand.cs index 5611bb1..73aed77 100644 --- a/PiwigoDirectorySync/Commands/ScanCommand.cs +++ b/PiwigoDirectorySync/Commands/ScanCommand.cs @@ -1,4 +1,6 @@ -using System.Diagnostics; +using System.ComponentModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Threading.Channels; using Microsoft.Extensions.Logging; using PiwigoDirectorySync.Infrastructure; @@ -7,7 +9,7 @@ using Spectre.Console.Cli; namespace PiwigoDirectorySync.Commands; -internal class ScanCommand : CancellableAsyncCommand +internal class ScanCommand : CancellableAsyncCommand { private readonly IFileIndexer _fileIndexer; private readonly IFileSystemScanner _fileSystemScanner; @@ -49,4 +51,12 @@ internal class ScanCommand : CancellableAsyncCommand //TODO: write failed files to log } + + [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] + internal class ScanSettings : CommonCommandSettings + { + [CommandOption("-d|--mark-for-delete")] + [DefaultValue(false)] + public bool MarkForDelete { get; set; } + } } \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/ScanSettings.cs b/PiwigoDirectorySync/Commands/ScanSettings.cs deleted file mode 100644 index cd1ff0d..0000000 --- a/PiwigoDirectorySync/Commands/ScanSettings.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using Spectre.Console.Cli; - -namespace PiwigoDirectorySync.Commands; - -[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] -internal class ScanSettings : CommonCommandSettings -{ - [CommandOption("-d|--mark-for-delete")] - [DefaultValue(false)] - public bool MarkForDelete { get; set; } -} \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/SyncAlbumsCommand.cs b/PiwigoDirectorySync/Commands/SyncAlbumsCommand.cs index cda9706..3c7caae 100644 --- a/PiwigoDirectorySync/Commands/SyncAlbumsCommand.cs +++ b/PiwigoDirectorySync/Commands/SyncAlbumsCommand.cs @@ -6,7 +6,7 @@ using Spectre.Console.Cli; namespace PiwigoDirectorySync.Commands; -internal class SyncAlbumsCommand : CancellableAsyncCommand +internal class SyncAlbumsCommand : CancellableAsyncCommand { private readonly IAlbumSynchronizer _albumSynchronizer; private readonly ILogger _logger; @@ -31,4 +31,8 @@ internal class SyncAlbumsCommand : CancellableAsyncCommand return 0; } + + internal class SyncAlbumsSettings : CommonCommandSettings + { + } } \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/SyncAlbumsSettings.cs b/PiwigoDirectorySync/Commands/SyncAlbumsSettings.cs deleted file mode 100644 index 9fe9b46..0000000 --- a/PiwigoDirectorySync/Commands/SyncAlbumsSettings.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace PiwigoDirectorySync.Commands; - -[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] -internal class SyncAlbumsSettings : CommonCommandSettings -{ -} \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/SyncFullCommand.cs b/PiwigoDirectorySync/Commands/SyncFullCommand.cs index add334a..0a9268e 100644 --- a/PiwigoDirectorySync/Commands/SyncFullCommand.cs +++ b/PiwigoDirectorySync/Commands/SyncFullCommand.cs @@ -6,7 +6,7 @@ using Spectre.Console.Cli; namespace PiwigoDirectorySync.Commands; -internal class SyncFullCommand : CancellableAsyncCommand +internal class SyncFullCommand : CancellableAsyncCommand { private readonly IAlbumSynchronizer _albumSynchronizer; private readonly IFileIndexer _fileIndexer; @@ -44,4 +44,8 @@ internal class SyncFullCommand : CancellableAsyncCommand return 0; } + + internal class SyncFullSettings : CommonCommandSettings + { + } } \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/SyncFullSettings.cs b/PiwigoDirectorySync/Commands/SyncFullSettings.cs deleted file mode 100644 index ce35e9b..0000000 --- a/PiwigoDirectorySync/Commands/SyncFullSettings.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace PiwigoDirectorySync.Commands; - -internal class SyncFullSettings : CommonCommandSettings {} \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/SyncImagesCommand.cs b/PiwigoDirectorySync/Commands/SyncImagesCommand.cs index ed7e43c..21fe96b 100644 --- a/PiwigoDirectorySync/Commands/SyncImagesCommand.cs +++ b/PiwigoDirectorySync/Commands/SyncImagesCommand.cs @@ -6,7 +6,7 @@ using Spectre.Console.Cli; namespace PiwigoDirectorySync.Commands; -internal class SyncImagesCommand : CancellableAsyncCommand +internal class SyncImagesCommand : CancellableAsyncCommand { private readonly IImageSynchronizer _imageSynchronizer; private readonly ILogger _logger; @@ -30,4 +30,8 @@ internal class SyncImagesCommand : CancellableAsyncCommand return 0; } + + internal class SyncImagesSettings : CommonCommandSettings + { + } } \ No newline at end of file diff --git a/PiwigoDirectorySync/Commands/SyncImagesSettings.cs b/PiwigoDirectorySync/Commands/SyncImagesSettings.cs deleted file mode 100644 index d84cb6f..0000000 --- a/PiwigoDirectorySync/Commands/SyncImagesSettings.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PiwigoDirectorySync.Commands; - -internal class SyncImagesSettings : CommonCommandSettings -{ -} \ No newline at end of file