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
|
// Options are static so the parsed values can be read back from both SetAction
|
||||||
// and the internal BuildRetryCommand / BuildDiscardCommand helpers (used by tests).
|
// 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 };
|
new("--site-id") { Description = "Site identifier of the parked operation", Required = true };
|
||||||
private static readonly Option<string> RetryMessageIdOption =
|
private static readonly Option<string> MessageIdOption =
|
||||||
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 =
|
|
||||||
new("--tracked-operation-id") { Description = "Tracked operation ID (MessageId) of the parked cached call", Required = true };
|
new("--tracked-operation-id") { Description = "Tracked operation ID (MessageId) of the parked cached call", Required = true };
|
||||||
|
|
||||||
/// <summary>
|
/// <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)
|
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" };
|
var cmd = new Command("retry") { Description = "Retry a parked cached-call operation" };
|
||||||
cmd.Add(RetrySiteIdOption);
|
cmd.Add(SiteIdOption);
|
||||||
cmd.Add(RetryMessageIdOption);
|
cmd.Add(MessageIdOption);
|
||||||
cmd.SetAction(async (ParseResult result) =>
|
cmd.SetAction(async (ParseResult result) =>
|
||||||
await CommandHelpers.ExecuteCommandAsync(
|
{
|
||||||
|
return await CommandHelpers.ExecuteCommandAsync(
|
||||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||||
BuildRetryCommand(result)));
|
BuildRetryCommand(result));
|
||||||
|
});
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Command BuildDiscard(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)
|
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" };
|
var cmd = new Command("discard") { Description = "Discard a parked cached-call operation" };
|
||||||
cmd.Add(DiscardSiteIdOption);
|
cmd.Add(SiteIdOption);
|
||||||
cmd.Add(DiscardMessageIdOption);
|
cmd.Add(MessageIdOption);
|
||||||
cmd.SetAction(async (ParseResult result) =>
|
cmd.SetAction(async (ParseResult result) =>
|
||||||
await CommandHelpers.ExecuteCommandAsync(
|
{
|
||||||
|
return await CommandHelpers.ExecuteCommandAsync(
|
||||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||||
BuildDiscardCommand(result)));
|
BuildDiscardCommand(result));
|
||||||
|
});
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +77,8 @@ public static class CachedCallCommands
|
|||||||
/// <returns>A <see cref="RetryParkedMessageCommand"/> populated from the parsed result.</returns>
|
/// <returns>A <see cref="RetryParkedMessageCommand"/> populated from the parsed result.</returns>
|
||||||
internal static RetryParkedMessageCommand BuildRetryCommand(ParseResult result)
|
internal static RetryParkedMessageCommand BuildRetryCommand(ParseResult result)
|
||||||
{
|
{
|
||||||
var siteId = result.GetValue(RetrySiteIdOption)!;
|
var siteId = result.GetValue(SiteIdOption)!;
|
||||||
var messageId = result.GetValue(RetryMessageIdOption)!;
|
var messageId = result.GetValue(MessageIdOption)!;
|
||||||
return new RetryParkedMessageCommand(siteId, messageId);
|
return new RetryParkedMessageCommand(siteId, messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +91,8 @@ public static class CachedCallCommands
|
|||||||
/// <returns>A <see cref="DiscardParkedMessageCommand"/> populated from the parsed result.</returns>
|
/// <returns>A <see cref="DiscardParkedMessageCommand"/> populated from the parsed result.</returns>
|
||||||
internal static DiscardParkedMessageCommand BuildDiscardCommand(ParseResult result)
|
internal static DiscardParkedMessageCommand BuildDiscardCommand(ParseResult result)
|
||||||
{
|
{
|
||||||
var siteId = result.GetValue(DiscardSiteIdOption)!;
|
var siteId = result.GetValue(SiteIdOption)!;
|
||||||
var messageId = result.GetValue(DiscardMessageIdOption)!;
|
var messageId = result.GetValue(MessageIdOption)!;
|
||||||
return new DiscardParkedMessageCommand(siteId, messageId);
|
return new DiscardParkedMessageCommand(siteId, messageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user