diff --git a/src/Nitride.Temporal/Nitride.Temporal.csproj b/src/Nitride.Temporal/Nitride.Temporal.csproj
index 686f311..60b7a1b 100644
--- a/src/Nitride.Temporal/Nitride.Temporal.csproj
+++ b/src/Nitride.Temporal/Nitride.Temporal.csproj
@@ -11,18 +11,18 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
diff --git a/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs b/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs
index c153d63..c640d55 100644
--- a/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs
+++ b/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs
@@ -17,68 +17,50 @@ public static class NitrideTemporalBuilderExtensions
/// Extends the builder to allow for configuring the temporal
/// settings for generation.
///
- public static NitrideBuilder UseTemporal(this NitrideBuilder builder, Action? configure = null)
+ public static NitrideBuilder UseTemporal(
+ this NitrideBuilder builder,
+ Action? configure = null)
{
- builder.ConfigureContainer(x => x.RegisterModule());
+ // Get the configuration so we can set the various options.
+ var config = new NitrideTemporalConfiguration();
- if (configure != null)
- {
- builder.ConfigureSite((_, scope) => configure(scope.Resolve()));
- }
+ configure?.Invoke(config);
+
+ // Add in the module registration.
+ builder.ConfigureContainer(
+ x =>
+ {
+ // Register the module.
+ x.RegisterModule();
+
+ // Add in the CLI options.
+ if (config.AddDateOptionToCommandLine)
+ {
+ x.RegisterType().As();
+ }
+
+ if (config.AddExpireOptionToCommandLine && config.Expiration != null)
+ {
+ x.Register(
+ context =>
+ {
+ ILogger logger = context.Resolve();
+ Timekeeper clock = context.Resolve();
+
+ return new Expires(logger, clock, config.Expiration);
+ })
+ .As();
+ }
+ });
+
+ builder.ConfigureSite(
+ (_, scope) =>
+ {
+ Timekeeper timekeeper = scope.Resolve();
+
+ timekeeper.DateTimeZone = timekeeper.DateTimeZone;
+ });
return builder;
}
-
- ///
- /// Adds the "--date=XXXX-XX-XX" option into the pipeline commands.
- ///
- /// The host builder being configured.
- /// The builder passed in.
- public static NitrideBuilder WithClockFromOptions(this NitrideBuilder builder)
- {
- return builder.UseTemporal()
- .ConfigureContainer(
- x =>
- {
- x.RegisterType().As();
- });
- }
-
- ///
- /// Adds the "--expire=XXXX" option into the pipeline commands where
- /// "XXX" is a format like "5y" or "500000:00:00.0". This is parsed by
- /// TimeSpanParser which gives an easy format.
- ///
- /// The host builder being configured.
- /// The default expiration, if one is provided.
- /// The builder passed in.
- public static NitrideBuilder WithExpiresFromOptions(this NitrideBuilder builder, TimeSpan defaultValue)
- {
- return WithExpiresFromOptions(builder, defaultValue.ToString());
- }
-
- ///
- /// Adds the "--expire=XXXX" option into the pipeline commands where
- /// "XXX" is a format like "5y" or "500000:00:00.0". This is parsed by
- /// TimeSpanParser which gives an easy format.
- ///
- /// The host builder being configured.
- /// The default expiration, if one is provided.
- /// The builder passed in.
- public static NitrideBuilder WithExpiresFromOptions(this NitrideBuilder builder, string? defaultValue = null)
- {
- return builder.ConfigureContainer(
- x =>
- {
- x.Register(
- context =>
- {
- ILogger? logger = context.Resolve();
- Timekeeper? clock = context.Resolve();
-
- return new Expires(logger, clock, defaultValue);
- })
- .As();
- });
- }
}
diff --git a/src/Nitride.Temporal/NitrideTemporalConfiguration.cs b/src/Nitride.Temporal/NitrideTemporalConfiguration.cs
new file mode 100644
index 0000000..67c196f
--- /dev/null
+++ b/src/Nitride.Temporal/NitrideTemporalConfiguration.cs
@@ -0,0 +1,50 @@
+using System;
+
+namespace Nitride.Temporal;
+
+///
+/// Configures the temporal settings for use with `UseTemporal`.
+///
+[WithProperties]
+public partial class NitrideTemporalConfiguration
+{
+ ///
+ /// Adds the "--date=XXXX-XX-XX" option into the pipeline commands.
+ ///
+ public bool AddDateOptionToCommandLine { get; set; }
+
+ public bool AddExpireOptionToCommandLine { get; set; }
+
+ ///
+ /// Gets or sets the time zone to use for date time operations. Examples would be
+ /// "America/Chicago".
+ ///
+ public string? DateTimeZone { get; set; }
+
+ public string? Expiration { get; set; }
+
+ ///
+ /// Adds the "--expire" option into the pipeline commands where with the value set
+ /// to
+ /// the current timestamp (or the one provided by --date) plus the given timespan
+ /// such
+ /// as "500000:00:00.0".
+ ///
+ public NitrideTemporalConfiguration WithExpiresCommandLineOption(TimeSpan? timeSpan)
+ {
+ return this.WithExpiresCommandLineOption(timeSpan?.ToString());
+ }
+
+ ///
+ /// Adds the "--expire=XXXX" option into the pipeline commands where
+ /// "XXX" is a format like "5y" or "500000:00:00.0". This is parsed by
+ /// TimeSpanParser which gives an easy format.
+ ///
+ public NitrideTemporalConfiguration WithExpiresCommandLineOption(string? defaultValue)
+ {
+ this.AddExpireOptionToCommandLine = defaultValue != null;
+ this.Expiration = defaultValue;
+
+ return this;
+ }
+}