tests fixes and sprints work
This commit is contained in:
@@ -33,55 +33,62 @@ public class AnchorCommandGroup
|
||||
|
||||
private Command BuildListCommand()
|
||||
{
|
||||
var outputOption = new Option<string>(
|
||||
name: "--output",
|
||||
getDefaultValue: () => "text",
|
||||
description: "Output format: text, json");
|
||||
var outputOption = new Option<string>("--output")
|
||||
{
|
||||
Description = "Output format: text, json"
|
||||
};
|
||||
outputOption.SetDefaultValue("text");
|
||||
|
||||
var listCommand = new Command("list", "List trust anchors")
|
||||
{
|
||||
outputOption
|
||||
};
|
||||
|
||||
listCommand.SetHandler(async (context) =>
|
||||
{
|
||||
var output = context.ParseResult.GetValueForOption(outputOption) ?? "text";
|
||||
context.ExitCode = await ListAnchorsAsync(output, context.GetCancellationToken());
|
||||
});
|
||||
listCommand.SetAction(async (parseResult, ct) =>
|
||||
await ListAnchorsAsync(
|
||||
parseResult.GetValue(outputOption) ?? "text",
|
||||
ct));
|
||||
|
||||
return listCommand;
|
||||
}
|
||||
|
||||
private Command BuildShowCommand()
|
||||
{
|
||||
var anchorArg = new Argument<Guid>("anchorId", "Trust anchor ID");
|
||||
var anchorArg = new Argument<Guid>("anchorId")
|
||||
{
|
||||
Description = "Trust anchor ID"
|
||||
};
|
||||
|
||||
var showCommand = new Command("show", "Show trust anchor details")
|
||||
{
|
||||
anchorArg
|
||||
};
|
||||
|
||||
showCommand.SetHandler(async (context) =>
|
||||
{
|
||||
var anchorId = context.ParseResult.GetValueForArgument(anchorArg);
|
||||
context.ExitCode = await ShowAnchorAsync(anchorId, context.GetCancellationToken());
|
||||
});
|
||||
showCommand.SetAction(async (parseResult, ct) =>
|
||||
await ShowAnchorAsync(
|
||||
parseResult.GetValue(anchorArg),
|
||||
ct));
|
||||
|
||||
return showCommand;
|
||||
}
|
||||
|
||||
private Command BuildCreateCommand()
|
||||
{
|
||||
var patternArg = new Argument<string>("pattern", "PURL glob pattern (e.g., pkg:npm/*)");
|
||||
var patternArg = new Argument<string>("pattern")
|
||||
{
|
||||
Description = "PURL glob pattern (e.g., pkg:npm/*)"
|
||||
};
|
||||
|
||||
var keyIdsOption = new Option<string[]>(
|
||||
aliases: ["-k", "--key-id"],
|
||||
description: "Allowed key IDs (can be repeated)")
|
||||
{ AllowMultipleArgumentsPerToken = true };
|
||||
var keyIdsOption = new Option<string[]>("--key-id", "-k")
|
||||
{
|
||||
Description = "Allowed key IDs (can be repeated)",
|
||||
AllowMultipleArgumentsPerToken = true
|
||||
};
|
||||
|
||||
var policyVersionOption = new Option<string?>(
|
||||
name: "--policy-version",
|
||||
description: "Policy version for this anchor");
|
||||
var policyVersionOption = new Option<string?>("--policy-version")
|
||||
{
|
||||
Description = "Policy version for this anchor"
|
||||
};
|
||||
|
||||
var createCommand = new Command("create", "Create a new trust anchor")
|
||||
{
|
||||
@@ -90,26 +97,32 @@ public class AnchorCommandGroup
|
||||
policyVersionOption
|
||||
};
|
||||
|
||||
createCommand.SetHandler(async (context) =>
|
||||
{
|
||||
var pattern = context.ParseResult.GetValueForArgument(patternArg);
|
||||
var keyIds = context.ParseResult.GetValueForOption(keyIdsOption) ?? [];
|
||||
var policyVersion = context.ParseResult.GetValueForOption(policyVersionOption);
|
||||
context.ExitCode = await CreateAnchorAsync(pattern, keyIds, policyVersion, context.GetCancellationToken());
|
||||
});
|
||||
createCommand.SetAction(async (parseResult, ct) =>
|
||||
await CreateAnchorAsync(
|
||||
parseResult.GetValue(patternArg),
|
||||
parseResult.GetValue(keyIdsOption) ?? [],
|
||||
parseResult.GetValue(policyVersionOption),
|
||||
ct));
|
||||
|
||||
return createCommand;
|
||||
}
|
||||
|
||||
private Command BuildRevokeKeyCommand()
|
||||
{
|
||||
var anchorArg = new Argument<Guid>("anchorId", "Trust anchor ID");
|
||||
var keyArg = new Argument<string>("keyId", "Key ID to revoke");
|
||||
var anchorArg = new Argument<Guid>("anchorId")
|
||||
{
|
||||
Description = "Trust anchor ID"
|
||||
};
|
||||
var keyArg = new Argument<string>("keyId")
|
||||
{
|
||||
Description = "Key ID to revoke"
|
||||
};
|
||||
|
||||
var reasonOption = new Option<string>(
|
||||
aliases: ["-r", "--reason"],
|
||||
getDefaultValue: () => "manual-revocation",
|
||||
description: "Reason for revocation");
|
||||
var reasonOption = new Option<string>("--reason", "-r")
|
||||
{
|
||||
Description = "Reason for revocation"
|
||||
};
|
||||
reasonOption.SetDefaultValue("manual-revocation");
|
||||
|
||||
var revokeCommand = new Command("revoke-key", "Revoke a key in a trust anchor")
|
||||
{
|
||||
@@ -118,13 +131,12 @@ public class AnchorCommandGroup
|
||||
reasonOption
|
||||
};
|
||||
|
||||
revokeCommand.SetHandler(async (context) =>
|
||||
{
|
||||
var anchorId = context.ParseResult.GetValueForArgument(anchorArg);
|
||||
var keyId = context.ParseResult.GetValueForArgument(keyArg);
|
||||
var reason = context.ParseResult.GetValueForOption(reasonOption) ?? "manual-revocation";
|
||||
context.ExitCode = await RevokeKeyAsync(anchorId, keyId, reason, context.GetCancellationToken());
|
||||
});
|
||||
revokeCommand.SetAction(async (parseResult, ct) =>
|
||||
await RevokeKeyAsync(
|
||||
parseResult.GetValue(anchorArg),
|
||||
parseResult.GetValue(keyArg),
|
||||
parseResult.GetValue(reasonOption) ?? "manual-revocation",
|
||||
ct));
|
||||
|
||||
return revokeCommand;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,16 @@ public class ReceiptCommandGroup
|
||||
|
||||
private Command BuildGetCommand()
|
||||
{
|
||||
var bundleArg = new Argument<string>("bundleId", "Proof bundle ID");
|
||||
var bundleArg = new Argument<string>("bundleId")
|
||||
{
|
||||
Description = "Proof bundle ID"
|
||||
};
|
||||
|
||||
var outputOption = new Option<string>(
|
||||
name: "--output",
|
||||
getDefaultValue: () => "text",
|
||||
description: "Output format: text, json, cbor");
|
||||
var outputOption = new Option<string>("--output")
|
||||
{
|
||||
Description = "Output format: text, json, cbor"
|
||||
};
|
||||
outputOption.SetDefaultValue("text");
|
||||
|
||||
var getCommand = new Command("get", "Get a verification receipt")
|
||||
{
|
||||
@@ -44,23 +48,26 @@ public class ReceiptCommandGroup
|
||||
outputOption
|
||||
};
|
||||
|
||||
getCommand.SetHandler(async (context) =>
|
||||
{
|
||||
var bundleId = context.ParseResult.GetValueForArgument(bundleArg);
|
||||
var output = context.ParseResult.GetValueForOption(outputOption) ?? "text";
|
||||
context.ExitCode = await GetReceiptAsync(bundleId, output, context.GetCancellationToken());
|
||||
});
|
||||
getCommand.SetAction(async (parseResult, ct) =>
|
||||
await GetReceiptAsync(
|
||||
parseResult.GetValue(bundleArg),
|
||||
parseResult.GetValue(outputOption) ?? "text",
|
||||
ct));
|
||||
|
||||
return getCommand;
|
||||
}
|
||||
|
||||
private Command BuildVerifyCommand()
|
||||
{
|
||||
var receiptFileArg = new Argument<FileInfo>("receiptFile", "Path to receipt file");
|
||||
var receiptFileArg = new Argument<FileInfo>("receiptFile")
|
||||
{
|
||||
Description = "Path to receipt file"
|
||||
};
|
||||
|
||||
var offlineOption = new Option<bool>(
|
||||
name: "--offline",
|
||||
description: "Offline mode (skip Rekor verification)");
|
||||
var offlineOption = new Option<bool>("--offline")
|
||||
{
|
||||
Description = "Offline mode (skip Rekor verification)"
|
||||
};
|
||||
|
||||
var verifyCommand = new Command("verify", "Verify a stored receipt")
|
||||
{
|
||||
@@ -68,12 +75,11 @@ public class ReceiptCommandGroup
|
||||
offlineOption
|
||||
};
|
||||
|
||||
verifyCommand.SetHandler(async (context) =>
|
||||
{
|
||||
var receiptFile = context.ParseResult.GetValueForArgument(receiptFileArg);
|
||||
var offline = context.ParseResult.GetValueForOption(offlineOption);
|
||||
context.ExitCode = await VerifyReceiptAsync(receiptFile, offline, context.GetCancellationToken());
|
||||
});
|
||||
verifyCommand.SetAction(async (parseResult, ct) =>
|
||||
await VerifyReceiptAsync(
|
||||
parseResult.GetValue(receiptFileArg),
|
||||
parseResult.GetValue(offlineOption),
|
||||
ct));
|
||||
|
||||
return verifyCommand;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user