2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.cmd;
24 import java.util.List;
26 import org.onap.aaf.cadi.CadiException;
27 import org.onap.aaf.cadi.LocatorException;
28 import org.onap.aaf.misc.env.APIException;
30 public class Help extends Cmd {
31 private List<Cmd> cmds;
33 public Help(AAFcli aafcli, List<Cmd> cmds) {
35 new Param("-d (more details)", false),
36 new Param("command",false));
41 public int _exec( int idxValue, final String ... args) throws CadiException, APIException, LocatorException {
44 StringBuilder sb = new StringBuilder("AAF Command Line Tool");
45 StringBuilder details;
46 multiChar(sb, 21, '-',0);
47 sb.append("\n SingleLine Commands");
48 multiChar(sb, 21, '-',2);
49 sb.append("\n force - add to regular commands to override depency checks");
50 sb.append("\n details - add to role list or perm list commands for rich format");
51 multiChar(sb, 48, '-',2);
52 // if details !=null, then extra details are written to it.
53 details = aafcli.isDetailed()?new StringBuilder():null;
55 String comp = args.length>idx?args[idx++]:null;
56 if ("help".equalsIgnoreCase(comp)) {
62 if (!(c instanceof DeprecatedCMD)) {
64 if (comp.equals(c.getName())) {
65 multiChar(sb,2,' ',0);
72 multiChar(sb,80,'-',2);
74 multiChar(sb,2,' ',0);
77 c.detailedHelp(4, sb);
83 pw().println(sb.toString());
84 return 200 /*HttpStatus.OK_200*/;
88 public void detailedHelp(int indentValue, StringBuilder sb) {
89 int indent = indentValue;
90 detailLine(sb,indent,"To print main help, enter \"aafcli\" or \"aafcli --help \"");
91 detailLine(sb,indent,"To print narrow the help content, enter sub-entries after aafcli,");
92 detailLine(sb,indent+2,"i.e. \"aafcli perm\"");
93 detailLine(sb,indent,"To see version of AAF CLI, enter \"aafcli --version \"");
95 detailLine(sb,indent,"State Commands: change variables or credentials between calls.");
97 detailLine(sb,indent,"set <tag>=<value> - Set any System Property to a new value");
98 detailLine(sb,indent,"as <id:password> - Change Credentials. Password may be encrypted");
99 detailLine(sb,indent,"expect <int> [int]* - In test mode, check for proper HTTP Status Codes");
100 detailLine(sb,indent,"sleep <int> - Wait for <int> seconds");
101 detailLine(sb,indent,"force - force deletions that have relationships");
102 detailLine(sb,indent,"details - cause list commands (role, perm) to print rich format");
103 detailLine(sb,indent," - In GUI CmdLine, use HourGlass option (top right)");
105 detailLine(sb,indent-4,"CmdLine Arguments: change behavior of the aafcli program");
106 detailLine(sb,indent,"-i - Read commands from Shell Standard Input");
107 detailLine(sb,indent,"-f - Read commands from a file");
108 detailLine(sb,indent,"-r - Clear Command Line SSO credential");
109 detailLine(sb,indent,"-a - In test mode, do not stop execution on unexpected error");
110 detailLine(sb,indent,"-t - Test Mode will not print variable fields that could break tc runs");
111 detailLine(sb,indent+6,"such as expiration dates of a credential");
112 detailLine(sb,indent,"-s - Request specific Start Date (not immediately)");
113 detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.STARTDATE + "=<value>\"");
114 detailLine(sb,indent,"-e - Set Expiration/End Date, where commands support");
115 detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.ENDDATE + "=<value>\"");