1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tools.metalava 18 19 import com.android.tools.metalava.cli.common.BaselineOptionsMixin 20 import com.android.tools.metalava.cli.common.CommonBaselineOptions 21 import com.android.tools.metalava.cli.common.ExecutionEnvironment 22 import com.android.tools.metalava.reporter.Reporter 23 import com.github.ajalt.clikt.parameters.groups.OptionGroup 24 import java.io.File 25 26 const val ARG_BASELINE = "--baseline" 27 const val ARG_UPDATE_BASELINE = "--update-baseline" 28 29 /** The name of the group, can be used in help text to refer to the options in this group. */ 30 const val GENERAL_REPORTER_OPTIONS_GROUP = "General Reporting" 31 32 /** 33 * Options related to the general [Reporter], i.e. not one specific to say API linting or 34 * compatibility checks. 35 */ 36 class GeneralReportingOptions( 37 executionEnvironment: ExecutionEnvironment = ExecutionEnvironment(), 38 commonBaselineOptions: CommonBaselineOptions = CommonBaselineOptions(), <lambda>null39 defaultBaselineFileProvider: () -> File? = { null }, 40 ) : 41 OptionGroup( 42 name = GENERAL_REPORTER_OPTIONS_GROUP, 43 help = 44 """ 45 Options that control the reporting of general issues, i.e. not API lint or 46 compatibility check issues. 47 """ 48 .trimIndent() 49 ) { 50 51 private val baselineOptionsMixin = 52 BaselineOptionsMixin( 53 containingGroup = this, 54 executionEnvironment, 55 baselineOptionName = ARG_BASELINE, 56 updateBaselineOptionName = ARG_UPDATE_BASELINE, 57 defaultBaselineFileProvider = defaultBaselineFileProvider, 58 issueType = "general", 59 description = "base", 60 commonBaselineOptions = commonBaselineOptions, 61 ) 62 63 internal val baseline by baselineOptionsMixin::baseline 64 } 65