fix(m9): CLI cached-call retry/discard propagate exit code (Task<int> overload)
Expression-bodied SetAction lambdas were binding to Func<ParseResult,Task> and discarding the int returned by ExecuteCommandAsync, so the process always exited 0 even on error/403. Switch both to block-body `return await` to select the Task<int> overload, matching every sibling command group. Also collapse the four duplicate static option fields (RetrySiteId/DiscardSiteId, RetryMessageId/DiscardMessageId) to two shared fields (SiteIdOption, MessageIdOption) — safe because retry and discard are sibling sub-commands.
This commit is contained in:
@@ -15,14 +15,11 @@ public static class CachedCallCommands
|
||||
{
|
||||
// Options are static so the parsed values can be read back from both SetAction
|
||||
// and the internal BuildRetryCommand / BuildDiscardCommand helpers (used by tests).
|
||||
private static readonly Option<string> RetrySiteIdOption =
|
||||
// A single shared instance per option is safe: retry and discard are sibling
|
||||
// sub-commands and cannot be invoked simultaneously.
|
||||
private static readonly Option<string> SiteIdOption =
|
||||
new("--site-id") { Description = "Site identifier of the parked operation", Required = true };
|
||||
private static readonly Option<string> RetryMessageIdOption =
|
||||
new("--tracked-operation-id") { Description = "Tracked operation ID (MessageId) of the parked cached call", Required = true };
|
||||
|
||||
private static readonly Option<string> DiscardSiteIdOption =
|
||||
new("--site-id") { Description = "Site identifier of the parked operation", Required = true };
|
||||
private static readonly Option<string> DiscardMessageIdOption =
|
||||
private static readonly Option<string> MessageIdOption =
|
||||
new("--tracked-operation-id") { Description = "Tracked operation ID (MessageId) of the parked cached call", Required = true };
|
||||
|
||||
/// <summary>
|
||||
@@ -46,24 +43,28 @@ public static class CachedCallCommands
|
||||
private static Command BuildRetry(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)
|
||||
{
|
||||
var cmd = new Command("retry") { Description = "Retry a parked cached-call operation" };
|
||||
cmd.Add(RetrySiteIdOption);
|
||||
cmd.Add(RetryMessageIdOption);
|
||||
cmd.Add(SiteIdOption);
|
||||
cmd.Add(MessageIdOption);
|
||||
cmd.SetAction(async (ParseResult result) =>
|
||||
await CommandHelpers.ExecuteCommandAsync(
|
||||
{
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||
BuildRetryCommand(result)));
|
||||
BuildRetryCommand(result));
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private static Command BuildDiscard(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)
|
||||
{
|
||||
var cmd = new Command("discard") { Description = "Discard a parked cached-call operation" };
|
||||
cmd.Add(DiscardSiteIdOption);
|
||||
cmd.Add(DiscardMessageIdOption);
|
||||
cmd.Add(SiteIdOption);
|
||||
cmd.Add(MessageIdOption);
|
||||
cmd.SetAction(async (ParseResult result) =>
|
||||
await CommandHelpers.ExecuteCommandAsync(
|
||||
{
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||
BuildDiscardCommand(result)));
|
||||
BuildDiscardCommand(result));
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -76,8 +77,8 @@ public static class CachedCallCommands
|
||||
/// <returns>A <see cref="RetryParkedMessageCommand"/> populated from the parsed result.</returns>
|
||||
internal static RetryParkedMessageCommand BuildRetryCommand(ParseResult result)
|
||||
{
|
||||
var siteId = result.GetValue(RetrySiteIdOption)!;
|
||||
var messageId = result.GetValue(RetryMessageIdOption)!;
|
||||
var siteId = result.GetValue(SiteIdOption)!;
|
||||
var messageId = result.GetValue(MessageIdOption)!;
|
||||
return new RetryParkedMessageCommand(siteId, messageId);
|
||||
}
|
||||
|
||||
@@ -90,8 +91,8 @@ public static class CachedCallCommands
|
||||
/// <returns>A <see cref="DiscardParkedMessageCommand"/> populated from the parsed result.</returns>
|
||||
internal static DiscardParkedMessageCommand BuildDiscardCommand(ParseResult result)
|
||||
{
|
||||
var siteId = result.GetValue(DiscardSiteIdOption)!;
|
||||
var messageId = result.GetValue(DiscardMessageIdOption)!;
|
||||
var siteId = result.GetValue(SiteIdOption)!;
|
||||
var messageId = result.GetValue(MessageIdOption)!;
|
||||
return new DiscardParkedMessageCommand(siteId, messageId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user