1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cmd;
\r
25 import java.util.List;
\r
27 import com.att.aft.dme2.internal.jetty.http.HttpStatus;
\r
28 import org.onap.aaf.cadi.CadiException;
\r
29 import org.onap.aaf.cadi.LocatorException;
\r
30 import org.onap.aaf.inno.env.APIException;
\r
32 public class Help extends Cmd {
\r
33 private List<Cmd> cmds;
\r
35 public Help(AAFcli aafcli, List<Cmd> cmds) {
\r
36 super(aafcli, "--help",
\r
37 new Param("-d (more details)", false),
\r
38 new Param("command",false));
\r
43 public int _exec( int _idx, final String ... args) throws CadiException, APIException, LocatorException {
\r
45 boolean first = true;
\r
46 StringBuilder sb = new StringBuilder("AAF Command Line Tool");
\r
47 StringBuilder details;
\r
48 if(aafcli.isDetailed() ){
\r
49 multiChar(sb, 21, '-',0);
\r
50 details=new StringBuilder();// use for temporary writing of details
\r
52 multiChar(sb, 21, '-',0);
\r
55 String comp = args.length>idx?args[idx++]:null;
\r
56 if("help".equalsIgnoreCase(comp)) {
\r
58 detailedHelp(4, sb);
\r
63 if(comp.equals(c.getName())) {
\r
64 multiChar(sb,2,' ',0);
\r
65 c.build(sb,details);
\r
71 multiChar(sb,80,'-',2);
\r
73 multiChar(sb,2,' ',0);
\r
74 c.build(sb,details);
\r
76 c.detailedHelp(4, sb);
\r
77 // multiChar(sb,80,'-',2);
\r
82 pw().println(sb.toString());
\r
83 return HttpStatus.OK_200;
\r
87 public void detailedHelp(int _indent, StringBuilder sb) {
\r
88 int indent = _indent;
\r
89 detailLine(sb,indent,"To print main help, enter \"aafcli\" or \"aafcli --help \"");
\r
90 detailLine(sb,indent,"To print narrow the help content, enter sub-entries after aafcli,");
\r
91 detailLine(sb,indent+2,"i.e. \"aafcli perm\"");
\r
92 detailLine(sb,indent,"To see version of AAF CLI, enter \"aafcli --version \"");
\r
94 detailLine(sb,indent,"State Commands: change variables or credentials between calls.");
\r
96 detailLine(sb,indent,"set <tag>=<value> - Set any System Property to a new value");
\r
97 detailLine(sb,indent,"as <id:password> - Change Credentials. Password may be encrypted");
\r
98 detailLine(sb,indent,"expect <int> [int]* - In test mode, check for proper HTTP Status Codes");
\r
99 detailLine(sb,indent,"sleep <int> - Wait for <int> seconds");
\r
101 detailLine(sb,indent-4,"CmdLine Arguments: change behavior of the aafcli program");
\r
102 detailLine(sb,indent,"-i - Read commands from Shell Standard Input");
\r
103 detailLine(sb,indent,"-f - Read commands from a file");
\r
104 detailLine(sb,indent,"-a - In test mode, do not stop execution on unexpected error");
\r
105 detailLine(sb,indent,"-t - Test Mode will not print variable fields that could break tc runs");
\r
106 detailLine(sb,indent+6,"such as expiration dates of a credential");
\r
107 detailLine(sb,indent,"-s - Request specific Start Date (not immediately)");
\r
108 detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.STARTDATE + "=<value>\"");
\r
109 detailLine(sb,indent,"-e - Set Expiration/End Date, where commands support");
\r
110 detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.ENDDATE + "=<value>\"");
\r