aboutsummaryrefslogtreecommitdiffstats
path: root/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/WrongArgumentError.kt
diff options
context:
space:
mode:
Diffstat (limited to 'hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/WrongArgumentError.kt')
-rw-r--r--hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/WrongArgumentError.kt70
1 files changed, 0 insertions, 70 deletions
diff --git a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/WrongArgumentError.kt b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/WrongArgumentError.kt
deleted file mode 100644
index 9c2a20c1..00000000
--- a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/WrongArgumentError.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * dcaegen2-collectors-veshv
- * ================================================================================
- * Copyright (C) 2018 NOKIA
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.dcae.collectors.veshv.utils.commandline
-
-import arrow.core.Option
-import org.apache.commons.cli.HelpFormatter
-import org.apache.commons.cli.Options
-
-
-data class WrongArgumentError(
- val message: String,
- val cause: Throwable? = null,
- val cmdLineOptionsList: List<CommandLineOption>) {
-
- constructor(par: Throwable, cmdLineOptionsList: List<CommandLineOption>) :
- this(par.message ?: "",
- par,
- cmdLineOptionsList)
-
- fun printMessage() {
- println(message)
- }
-
- fun printHelp(programName: String) {
- val formatter = HelpFormatter()
- val footer = "All parameters can be specified as environment variables using upper-snake-case full " +
- "name with prefix `VESHV_`."
-
- formatter.printHelp(
- programName,
- generateRequiredParametersNote(cmdLineOptionsList),
- getOptions(),
- footer)
- }
-
- private fun getOptions() = cmdLineOptionsList.map { it.option }.fold(Options(), Options::addOption)
-
- companion object {
- fun generateRequiredParametersNote(cmdLineOptionsList: List<CommandLineOption>): String {
- val requiredParams = Option.fromNullable(cmdLineOptionsList.filter { it.required }
- .takeUnless { it.isEmpty() })
- return requiredParams.fold(
- { "" },
- {
- it.map { commandLineOption -> commandLineOption.option.opt }
- .joinToString(prefix = "Required parameters: ", separator = ", ")
- }
- )
- }
- }
-
-}
-