feat(cli): notification smtp update --transport smtp|ews

This commit is contained in:
Joseph Doherty
2026-08-10 06:35:33 -04:00
parent 4e633b1e64
commit 0fe1972960
2 changed files with 64 additions and 7 deletions
@@ -144,6 +144,7 @@ public static class NotificationCommands
updateCmd.Add(SmtpCredentialsOption);
updateCmd.Add(SmtpOAuth2AuthorityOption);
updateCmd.Add(SmtpOAuth2ScopeOption);
updateCmd.Add(SmtpTransportOption);
updateCmd.SetAction(async (ParseResult result) =>
{
return await CommandHelpers.ExecuteCommandAsync(
@@ -187,6 +188,20 @@ public static class NotificationCommands
"(optional; preserves existing / M365 default if omitted)",
};
private static readonly Option<string?> SmtpTransportOption = CreateTransportOption();
private static Option<string?> CreateTransportOption()
{
var option = new Option<string?>("--transport")
{
Description = "Email transport: Smtp or Ews (optional; preserves existing if omitted). " +
"Under Ews, --server is the full EWS URL (https://…/ews/exchange.asmx), " +
"--auth-mode must be basic, and --port/--tls-mode are unused.",
};
option.AcceptOnlyFromAmong("Smtp", "Ews");
return option;
}
private static Option<string?> CreateTlsModeOption()
{
var option = new Option<string?>("--tls-mode")
@@ -200,8 +215,8 @@ public static class NotificationCommands
/// <summary>
/// Builds the <see cref="UpdateSmtpConfigCommand"/> from a parsed <c>smtp update</c>
/// invocation. The optional <c>--tls-mode</c> / <c>--credentials</c> /
/// <c>--oauth2-authority</c> / <c>--oauth2-scope</c> flags map to null when omitted
/// so the server-side handler preserves the existing values.
/// <c>--oauth2-authority</c> / <c>--oauth2-scope</c> / <c>--transport</c> flags map to
/// null when omitted so the server-side handler preserves the existing values.
/// </summary>
/// <param name="result">The parsed command-line result from the <c>smtp update</c> invocation.</param>
/// <returns>An <see cref="UpdateSmtpConfigCommand"/> populated from the parsed result.</returns>
@@ -216,7 +231,8 @@ public static class NotificationCommands
var credentials = result.GetValue(SmtpCredentialsOption);
var oauth2Authority = result.GetValue(SmtpOAuth2AuthorityOption);
var oauth2Scope = result.GetValue(SmtpOAuth2ScopeOption);
return new UpdateSmtpConfigCommand(id, server, port, authMode, from, tlsMode, credentials, oauth2Authority, oauth2Scope);
var transport = result.GetValue(SmtpTransportOption);
return new UpdateSmtpConfigCommand(id, server, port, authMode, from, tlsMode, credentials, oauth2Authority, oauth2Scope, transport);
}
private static Command BuildSms(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)