--- /dev/null
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ * * http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ * * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cmd;\r
+\r
+import java.util.List;\r
+\r
+import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
+import org.onap.aaf.cadi.CadiException;\r
+import org.onap.aaf.cadi.LocatorException;\r
+import org.onap.aaf.inno.env.APIException;\r
+\r
+public class Help extends Cmd {\r
+ private List<Cmd> cmds;\r
+\r
+ public Help(AAFcli aafcli, List<Cmd> cmds) {\r
+ super(aafcli, "--help", \r
+ new Param("-d (more details)", false),\r
+ new Param("command",false));\r
+ this.cmds = cmds;\r
+ }\r
+\r
+ @Override\r
+ public int _exec( int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
+ int idx = _idx;\r
+ boolean first = true;\r
+ StringBuilder sb = new StringBuilder("AAF Command Line Tool");\r
+ StringBuilder details;\r
+ if(aafcli.isDetailed() ){\r
+ multiChar(sb, 21, '-',0);\r
+ details=new StringBuilder();// use for temporary writing of details\r
+ } else {\r
+ multiChar(sb, 21, '-',0);\r
+ details = null;\r
+ }\r
+ String comp = args.length>idx?args[idx++]:null;\r
+ if("help".equalsIgnoreCase(comp)) {\r
+ build(sb,null);\r
+ detailedHelp(4, sb);\r
+ sb.append('\n');\r
+ } else {\r
+ for(Cmd c : cmds) {\r
+ if(comp!=null) {\r
+ if(comp.equals(c.getName())) {\r
+ multiChar(sb,2,' ',0);\r
+ c.build(sb,details);\r
+ }\r
+ } else {\r
+ if(first) {\r
+ first=false;\r
+ } else {\r
+ multiChar(sb,80,'-',2);\r
+ }\r
+ multiChar(sb,2,' ',0);\r
+ c.build(sb,details);\r
+ if(details!=null) {\r
+ c.detailedHelp(4, sb);\r
+// multiChar(sb,80,'-',2);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ pw().println(sb.toString());\r
+ return HttpStatus.OK_200;\r
+ }\r
+ \r
+ @Override\r
+ public void detailedHelp(int _indent, StringBuilder sb) {\r
+ int indent = _indent;\r
+ detailLine(sb,indent,"To print main help, enter \"aafcli\" or \"aafcli --help \"");\r
+ detailLine(sb,indent,"To print narrow the help content, enter sub-entries after aafcli,");\r
+ detailLine(sb,indent+2,"i.e. \"aafcli perm\"");\r
+ detailLine(sb,indent,"To see version of AAF CLI, enter \"aafcli --version \"");\r
+ sb.append('\n');\r
+ detailLine(sb,indent,"State Commands: change variables or credentials between calls.");\r
+ indent+=4;\r
+ detailLine(sb,indent,"set <tag>=<value> - Set any System Property to a new value");\r
+ detailLine(sb,indent,"as <id:password> - Change Credentials. Password may be encrypted");\r
+ detailLine(sb,indent,"expect <int> [int]* - In test mode, check for proper HTTP Status Codes");\r
+ detailLine(sb,indent,"sleep <int> - Wait for <int> seconds");\r
+ sb.append('\n');\r
+ detailLine(sb,indent-4,"CmdLine Arguments: change behavior of the aafcli program");\r
+ detailLine(sb,indent,"-i - Read commands from Shell Standard Input");\r
+ detailLine(sb,indent,"-f - Read commands from a file");\r
+ detailLine(sb,indent,"-a - In test mode, do not stop execution on unexpected error");\r
+ detailLine(sb,indent,"-t - Test Mode will not print variable fields that could break tc runs");\r
+ detailLine(sb,indent+6,"such as expiration dates of a credential");\r
+ detailLine(sb,indent,"-s - Request specific Start Date (not immediately)");\r
+ detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.STARTDATE + "=<value>\"");\r
+ detailLine(sb,indent,"-e - Set Expiration/End Date, where commands support");\r
+ detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.ENDDATE + "=<value>\"");\r
+ }\r
+}\r