Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

fix(cli): show the platform's default watch settle time

Blackspirits21a948cd33ae
diff --git a/src/Filee.Cli/Help.cs b/src/Filee.Cli/Help.cs
index 3ec9e02f..b7c81f06 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 @@ internal static class Help
""";
- private const string Watch = """
+ private static string Watch => FormattableString.Invariant($"""
Usage: filee watch <folder> (--to <format> | --preset <preset>) [options]
Converts files that land in the folder until Ctrl+C. Files are converted once they are complete (no
@@ -74,10 +75,10 @@ internal static class Help
-r, --recursive Also watch sub folders (their files keep the sub folder in the output)
--move-originals Move converted sources to <folder>\originals; files already waiting are
converted at start
- --settle <seconds> How long a file must stay unchanged (default 2)
+ --settle <seconds> 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 00000000..f18af3fb
--- /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 <seconds> How long a file must stay unchanged (default {FolderWatcher.DefaultSettleTime.TotalSeconds})"), output.ToString());
+ }
+}