2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2021 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.auth.clieditor.tosca;
23 import org.apache.commons.cli.Option;
24 import org.onap.policy.apex.auth.clieditor.CommandLineParameterParser;
27 * This class reads and handles command line parameters to the Apex CLI Tosca editor.
29 * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
31 public class ApexCliToscaParameterParser extends CommandLineParameterParser {
34 * Construct the options for the CLI editor.
36 public ApexCliToscaParameterParser() {
37 getOptions().addOption(Option.builder("ac").longOpt("apex-config-file")
38 .desc("name of the file containing apex configuration details").hasArg()
39 .argName("APEX_CONFIG_FILE").required(false).type(String.class).build());
40 getOptions().addOption(Option.builder("t").longOpt("tosca-template-file")
41 .desc("name of the input file containing tosca template which needs to be updated with policy").hasArg()
42 .argName("TOSCA_TEMPLATE_FILE").required(false).type(String.class).build());
43 getOptions().addOption(Option.builder("ot").longOpt("output-tosca-file")
44 .desc("name of a file that will contain the output model for the editor").hasArg()
45 .argName("OUTPUT_TOSCA_FILE").required(false).type(String.class).build());
49 * Parse the command line options.
51 * @param args The arguments
52 * @return the CLI parameters
55 public ApexCliToscaParameters parse(final String[] args) {
56 var commandLine = parseDefault(args);
57 final var parameters = new ApexCliToscaParameters();
58 parseSingleLetterOptions(commandLine, parameters);
59 parseDoubleLetterOptions(commandLine, parameters);
61 if (commandLine.hasOption("ac")) {
62 parameters.setApexConfigFileName(commandLine.getOptionValue("ac"));
64 if (commandLine.hasOption("t")) {
65 parameters.setInputToscaTemplateFileName(commandLine.getOptionValue("t"));
67 if (commandLine.hasOption("ot")) {
68 parameters.setOutputToscaPolicyFileName(commandLine.getOptionValue("ot"));