From acfeb11d862c8871cfc121d4e003a344076f8be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Tue, 16 Apr 2024 10:30:26 +0200 Subject: [PATCH] check-flagged-apis: add support for command line options Use clikt as the command line options parser library. Bug: 334870672 Test: m check-flagged-apis && check-flagged-apis Change-Id: I7c406456b00e29293294dcdbef411d2543a1e8d5 --- tools/check-flagged-apis/Android.bp | 3 +++ .../src/com/android/checkflaggedapis/Main.kt | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/check-flagged-apis/Android.bp b/tools/check-flagged-apis/Android.bp index 4695ca0338..209c89b9a7 100644 --- a/tools/check-flagged-apis/Android.bp +++ b/tools/check-flagged-apis/Android.bp @@ -21,5 +21,8 @@ java_binary_host { srcs: [ "src/**/*.kt", ], + static_libs: [ + "metalava-tools-common-m2-deps", + ], main_class: "com.android.checkflaggedapis.Main", } 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 dee4fdbe3c..ecb2675ac8 100644 --- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt +++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt @@ -17,4 +17,14 @@ package com.android.checkflaggedapis -fun main() = println("hello world") +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.ProgramResult + +class CheckCommand : CliktCommand() { + override fun run() { + println("hello world") + throw ProgramResult(0) + } +} + +fun main(args: Array) = CheckCommand().main(args)