From 576e818880d044c277dc4eed89f2f1fff5c4072b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Mon, 10 Jun 2024 15:33:12 +0200 Subject: [PATCH] check-flagged-apis: extract argument names into constants Extract the command line argument names (and help texts) into constants. This will allow future subcommands to re-use the same names and keep things consistent. Bug: 345207706 Test: atest check-flagged-apis-test Flag: EXEMPT host side tool Change-Id: I430f36c99f28aab8511a357f572086ee238d653b --- .../src/com/android/checkflaggedapis/Main.kt | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt index 26d3c9c40b..4696efd136 100644 --- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt +++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt @@ -142,6 +142,29 @@ internal data class UnknownFlagError(override val symbol: Symbol, override val f } } +val ARG_API_SIGNATURE = "--api-signature" +val ARG_API_SIGNATURE_HELP = + """ +Path to API signature file. +Usually named *current.txt. +Tip: `m frameworks-base-api-current.txt` will generate a file that includes all platform and mainline APIs. +""" + +val ARG_FLAG_VALUES = "--flag-values" +val ARG_FLAG_VALUES_HELP = + """ +Path to aconfig parsed_flags binary proto file. +Tip: `m all_aconfig_declarations` will generate a file that includes all information about all flags. +""" + +val ARG_API_VERSIONS = "--api-versions" +val ARG_API_VERSIONS_HELP = + """ +Path to API versions XML file. +Usually named xml-versions.xml. +Tip: `m sdk dist` will generate a file that includes all platform and mainline APIs. +""" + class MainCommand : CliktCommand() { override fun run() {} } @@ -157,32 +180,18 @@ This tool reads the API signature file and checks that all flagged APIs are used The tool will exit with a non-zero exit code if any flagged APIs are found to be used in the incorrect way. """) { private val apiSignaturePath by - option("--api-signature") - .help( - """ - Path to API signature file. - Usually named *current.txt. - Tip: `m frameworks-base-api-current.txt` will generate a file that includes all platform and mainline APIs. - """) + option(ARG_API_SIGNATURE) + .help(ARG_API_SIGNATURE_HELP) .path(mustExist = true, canBeDir = false, mustBeReadable = true) .required() private val flagValuesPath by - option("--flag-values") - .help( - """ - Path to aconfig parsed_flags binary proto file. - Tip: `m all_aconfig_declarations` will generate a file that includes all information about all flags. - """) + option(ARG_FLAG_VALUES) + .help(ARG_FLAG_VALUES_HELP) .path(mustExist = true, canBeDir = false, mustBeReadable = true) .required() private val apiVersionsPath by - option("--api-versions") - .help( - """ - Path to API versions XML file. - Usually named xml-versions.xml. - Tip: `m sdk dist` will generate a file that includes all platform and mainline APIs. - """) + option(ARG_API_VERSIONS) + .help(ARG_API_VERSIONS_HELP) .path(mustExist = true, canBeDir = false, mustBeReadable = true) .required()