diff --git a/src/Filee.Cli/Help.cs b/src/Filee.Cli/Help.cs index 3ec9e02f9..b7c81f06a 100644 --- a/src/Filee.Cli/Help.cs +++ b/src/Filee.Cli/Help.cs @@ -1,6 +1,7 @@ // Usage text of the "filee" command. using System.Reflection; +using Filee.Core.Watching; namespace Filee.Cli; @@ -61,7 +62,7 @@ Files can be wildcards (*.heic). Folders convert the files in them that Filee kn """; - private const string Watch = """ + private static string Watch => FormattableString.Invariant($""" Usage: filee watch (--to | --preset ) [options] Converts files that land in the folder until Ctrl+C. Files are converted once they are complete (no @@ -74,10 +75,10 @@ Files can be wildcards (*.heic). Folders convert the files in them that Filee kn -r, --recursive Also watch sub folders (their files keep the sub folder in the output) --move-originals Move converted sources to \originals; files already waiting are converted at start - --settle How long a file must stay unchanged (default 2) + --settle How long a file must stay unchanged (default {FolderWatcher.DefaultSettleTime.TotalSeconds}) --keep-dates Give converted files the created and modified dates of the originals --zip Save the result of each file as one ZIP (a Shapefile's files together) --quiet Print nothing but errors - """; + """); } diff --git a/tests/Filee.Cli.Tests/HelpTests.cs b/tests/Filee.Cli.Tests/HelpTests.cs new file mode 100644 index 000000000..f18af3fb3 --- /dev/null +++ b/tests/Filee.Cli.Tests/HelpTests.cs @@ -0,0 +1,26 @@ +// CLI help must describe the watcher's platform default without loading settings or engines. + +using Filee.Core.Watching; + +namespace Filee.Cli.Tests; + +public sealed class HelpTests +{ + [Theory] + [InlineData("help", "watch")] + [InlineData("watch", "--help")] + [InlineData("watch", "-h")] + public async Task Watch_help_reports_the_platform_default_without_loading_engines(string command, string option) + { + var output = new StringWriter(); + var errors = new StringWriter(); + + var code = await Cli.RunAsync([command, option], output, errors, TestContext.Current.CancellationToken, + () => throw new InvalidOperationException("Help must not initialize engines.")); + + Assert.Equal(Cli.Success, code); + Assert.Equal("", errors.ToString()); + Assert.Contains(FormattableString.Invariant( + $"--settle How long a file must stay unchanged (default {FolderWatcher.DefaultSettleTime.TotalSeconds})"), output.ToString()); + } +}