/* * * * ============LICENSE_START======================================================= * * org.onap.dcae * * ================================================================================ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. * * ================================================================================ * * 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.blueprintgenerator.service.common; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.CommandLine; import org.onap.blueprintgenerator.model.common.Input; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import static java.lang.System.exit; /** * @author : Ravi Mantena * @date 10/16/2020 * Application: ONAP - Blueprint Generator * Common ONAP Service used by ONAP and DMAAP Blueprint to Print Instructions and Parse Inputs */ @Service("onapCommonUtilsService") public class CommonUtils { public void printInstructions() { System.out.println("OPTIONS:"); System.out.println("-i OR --component-spec: The path of the ONAP Blueprint INPUT JSON SPEC FILE (Required)"); System.out.println("-p OR --blueprint-path: The path of the ONAP Blueprint OUTPUT where it will be saved (Required)"); System.out.println("-n OR --blueprint-name: The NAME of the ONAP Blueprint OUTPUT that will be created (Optional)"); System.out.println("-t OR --imports: The path of the ONAP Blueprint IMPORT FILE (Optional)"); System.out.println("-o OR --service-name-override: The Value used to OVERRIDE the SERVICE NAME of the ONAP Blueprint (Optional)"); System.out.println("-d OR --dmaap-plugin: The option to create a ONAP Blueprint with DMAAP Plugin (Optional)"); System.out.println("Syntax to run from command line: \n For Blueprint : java -jar target/.jar app ONAP -i componentspec -p OutputBlueprintPath -n Blueprintname -d \n For PolicyCreate: java -jar target/.jar app ONAP -type policycreate -i componentspec -p OutputPolicyPath"); } public Input parseInputs(String[] args) { String[] modArgs = new String[args.length]; for(int i=0; i