diff --git a/java/arcs/tools/README.md b/java/arcs/tools/README.md index 5f2d507fc1a..d462b71af4d 100644 --- a/java/arcs/tools/README.md +++ b/java/arcs/tools/README.md @@ -46,3 +46,15 @@ into textprotos. ``` $ bazel run --run_under="cd $PWD && " //java/arcs/tools:inspect_manifest -- ./ok_check_multiple_or_tags.binarypb ./ok_check_multiple_or_tags.textproto ``` + +## verify_policy + +Verifies that all recipes in an Arcs manifest file comply with their policies. + +``` +# bazel run //java/arcs/tools:verify_policy -- /absolute/path/to/binary_manifest.binarypb +``` + +Options: +- `-d, --debug`: Turn on debug tracing +- `--help`: Display usage info diff --git a/java/arcs/tools/VerifyPolicy.kt b/java/arcs/tools/VerifyPolicy.kt index 8f00c9dc7c2..d42fcdb0f97 100644 --- a/java/arcs/tools/VerifyPolicy.kt +++ b/java/arcs/tools/VerifyPolicy.kt @@ -4,21 +4,30 @@ import arcs.core.analysis.PolicyVerifier import arcs.core.data.proto.ManifestProto import arcs.core.data.proto.decodeRecipes import arcs.core.policy.proto.decode +import arcs.core.util.Log import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktError +import com.github.ajalt.clikt.parameters.arguments.argument +import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required import com.github.ajalt.clikt.parameters.types.file class VerifyPolicy : CliktCommand( name = "verify_policy", - help = "Verifies that all recipes in an Arcs manifest file comply with their policies." + help = "Verifies that all recipes in an Arcs manifest file comply with their policies.", + printHelpOnEmptyArgs = true ) { - val manifest by option( + val manifest by argument( help = "Arcs manifest to check, encoded as a binary proto file (.binarypb)" - ).file().required() + ).file() + + val debug by option("-d", "--debug", help = "Turn on debug tracing") + .flag(default = false) override fun run() { + if (debug) { + Log.level = Log.Level.Debug + } val manifestProto = ManifestProto.parseFrom(manifest.readBytes()) val recipes = manifestProto.decodeRecipes() diff --git a/third_party/java/arcs/build_defs/internal/tools.oss.bzl b/third_party/java/arcs/build_defs/internal/tools.oss.bzl index e25e545f639..1d9e8567312 100644 --- a/third_party/java/arcs/build_defs/internal/tools.oss.bzl +++ b/third_party/java/arcs/build_defs/internal/tools.oss.bzl @@ -74,7 +74,6 @@ def arcs_tool_verify_policy(name, manifest_proto): name = name, test_binary = "//java/arcs/tools:verify_policy", test_args = [ - "--manifest", "$(rootpath %s)" % manifest_proto, ], data = [