From 47bc010b3cfbde0a6bd33cb01e6497a3490d2603 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Sat, 7 Dec 2013 15:22:51 +0100 Subject: [PATCH] Added test-filters command --- Duplicati/CommandLine/Commands.cs | 20 + Duplicati/CommandLine/Program.cs | 1 + Duplicati/CommandLine/help.txt | 813 +++++++++--------- .../Library/Interface/ResultInterfaces.cs | 7 + Duplicati/Library/Main/Controller.cs | 11 + .../Main/Duplicati.Library.Main.csproj | 1 + Duplicati/Library/Main/Enums.cs | 3 +- .../Library/Main/Operation/BackupHandler.cs | 115 ++- .../Main/Operation/TestFilterHandler.cs | 93 ++ Duplicati/Library/Main/ResultClasses.cs | 9 + .../Modules/Builtin/ConsolePasswordInput.cs | 2 +- Duplicati/Library/Utility/FilterExpression.cs | 50 +- Duplicati/Library/Utility/IFilter.cs | 11 +- .../Library/Utility/JoinedFilterExpression.cs | 14 +- Duplicati/Library/Utility/Utility.cs | 3 +- 15 files changed, 694 insertions(+), 459 deletions(-) create mode 100644 Duplicati/Library/Main/Operation/TestFilterHandler.cs diff --git a/Duplicati/CommandLine/Commands.cs b/Duplicati/CommandLine/Commands.cs index 8fbed1b63..f569d9ed9 100644 --- a/Duplicati/CommandLine/Commands.cs +++ b/Duplicati/CommandLine/Commands.cs @@ -695,6 +695,26 @@ namespace Duplicati.CommandLine return 0; } + + public static int TestFilters(List args, Dictionary options, Library.Utility.IFilter filter) + { + if (args == null || args.Count < 1) + { + Console.WriteLine("No source paths given"); + return 200; + } + + options["verbose"] = "true"; + + using(var i = new Library.Main.Controller("dummy://", options, new ConsoleOutput(options))) + { + var result = i.TestFilter(args.ToArray(), filter); + + Console.WriteLine("Matched {0} files ({1})", result.FileCount, Duplicati.Library.Utility.Utility.FormatSizeString(result.FileSize)); + } + + return 0; + } } } diff --git a/Duplicati/CommandLine/Program.cs b/Duplicati/CommandLine/Program.cs index 5d430f17b..e3406ffc5 100644 --- a/Duplicati/CommandLine/Program.cs +++ b/Duplicati/CommandLine/Program.cs @@ -183,6 +183,7 @@ namespace Duplicati.CommandLine knownCommands["compare"] = Commands.ListChanges; knownCommands["test"] = Commands.Test; knownCommands["verify"] = Commands.Test; + knownCommands["test-filters"] = Commands.TestFilters; if (verbose) { diff --git a/Duplicati/CommandLine/help.txt b/Duplicati/CommandLine/help.txt index 195181e42..4919d9796 100644 --- a/Duplicati/CommandLine/help.txt +++ b/Duplicati/CommandLine/help.txt @@ -1,403 +1,412 @@ -# This file is the help for the Duplicati Command Line Client. It shows what -# commands the CLI understands and what the outputs are. Sometimes we used -# placeholders for options. In that case descriptions are taken directly from -# the modules. Sometimes we described options here. The reason for that is, -# that we found the new description much better but did not want to create a -# need for translation as many options are described in the UI as well and -# they are translated there. -# ============================================================================= -> duplicati.commandline.exe -> duplicati.commandline.exe help - -See duplicati.commandline.exe help for more information. - Examples: example - Commands: backup, find, restore, delete, compact, test, compare, repair - Debugging: debug, logging, create-report - Targets: %BACKENDS% - Modules: %ENCRYPTIONMODULES%, %COMPRESSIONMODULES%, %GENERICMODULES% - Formats: date, time, size, encryption, compression - Advanced: mail, advanced, returncodes, filter,