diff --git a/source/Models/CommandLineOptions/GenerateOptions.cs b/source/Models/CommandLineOptions/GenerateOptions.cs index d14eba2b74e03ce739621569b0e6d74a4337930c..eb50030a3990e1de1159383fd59a872de56c63cb 100644 --- a/source/Models/CommandLineOptions/GenerateOptions.cs +++ b/source/Models/CommandLineOptions/GenerateOptions.cs @@ -10,4 +10,7 @@ internal class GenerateOptions : IGenerateOptions /// public bool Future { get; init; } + + /// + public bool Expired { get; init; } } diff --git a/source/Models/CommandLineOptions/IGenerateOptions.cs b/source/Models/CommandLineOptions/IGenerateOptions.cs index 472bb541a09ad7e51b7681b168d6b40a33d74fd7..74e249af077fe7832cd8203f30c7730dd41bfa14 100644 --- a/source/Models/CommandLineOptions/IGenerateOptions.cs +++ b/source/Models/CommandLineOptions/IGenerateOptions.cs @@ -11,7 +11,12 @@ public interface IGenerateOptions string Source { get; } /// - /// Consider + /// Consider future content /// bool Future { get; } + + /// + /// Consider expired content + /// + bool Expired { get; } } \ No newline at end of file diff --git a/source/Models/Site.cs b/source/Models/Site.cs index 65a517d68b4702c824bf96c398a35e97f3eb6b17..f2e353deb772424f238ba89eaca0f09d6865a09d 100644 --- a/source/Models/Site.cs +++ b/source/Models/Site.cs @@ -411,7 +411,8 @@ internal class Site : ISite { throw new ArgumentNullException(nameof(frontMatter)); } - return !IsDateExpired(frontMatter) && (IsDatePublishable(frontMatter) || (options?.Future ?? false)); + return (!IsDateExpired(frontMatter) || (options?.Expired ?? false)) + && (IsDatePublishable(frontMatter) || (options?.Future ?? false)); } /// diff --git a/source/Program.cs b/source/Program.cs index cabc01ad470bc2a2d82a14b98970ffd9965308e1..59e04c31fd2292e43db16e54ae69500bbd40e806 100644 --- a/source/Program.cs +++ b/source/Program.cs @@ -53,6 +53,7 @@ internal class Program // Shared options between the commands var sourceOption = new Option(new[] { "--source", "-s" }, () => ".", "Source directory path"); var futureOption = new Option(new[] { "--future", "-f" }, "Include content with dates in the future"); + var expiredOption = new Option(new[] { "--expired", "-e" }, "Include content with ExpiredDate dates from the past"); var verboseOption = new Option(new[] { "--verbose", "-v" }, "Verbose output"); // BuildCommand setup @@ -63,9 +64,10 @@ internal class Program sourceOption, buildOutputOption, futureOption, + expiredOption, verboseOption }; - buildCommandHandler.SetHandler((source, output, future, verbose) => + buildCommandHandler.SetHandler((source, output, future, expired, verbose) => { logger = CreateLogger(verbose); @@ -73,34 +75,37 @@ internal class Program source: source, output: output) { - Future = future + Future = future, + Expired = expired }; _ = new BuildCommand(buildOptions, logger); }, - sourceOption, buildOutputOption, futureOption, verboseOption); + sourceOption, buildOutputOption, futureOption, expiredOption, verboseOption); // ServerCommand setup Command serveCommandHandler = new("serve", "Starts the server") { sourceOption, futureOption, + expiredOption, verboseOption }; - serveCommandHandler.SetHandler(async (source, future, verbose) => + serveCommandHandler.SetHandler(async (source, future, expired, verbose) => { logger = CreateLogger(verbose); ServeOptions serverOptions = new() { Source = source, - Future = future + Future = future, + Expired = expired }; var serveCommand = new ServeCommand(serverOptions, logger, new SourceFileWatcher()); await serveCommand.RunServer(); await Task.Delay(-1); // Wait forever. }, - sourceOption, futureOption, verboseOption); + sourceOption, futureOption, expiredOption, verboseOption); RootCommand rootCommand = new("SuCoS commands") {