To fix EDKT284.
[mirror_edk2.git] / Tools / Source / ContextTool / org / tianocore / context / HelpInfo.java
CommitLineData
987912ad 1/** @file\r
2 File is HelpInfo class which is used to output the usage info. \r
3 \r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13\r
c74c7a43 14package org.tianocore.context;\r
15\r
67ce7c51 16import java.util.LinkedList;\r
17\r
c74c7a43 18public class HelpInfo {\r
19\r
20 \r
21 /** \r
22 * output the tools usage guide\r
23 * @param no input parameter\r
24 * @return no return value\r
25 **/\r
26 public static void outputUsageInfo() {\r
2c71f6e5 27 System.out.printf("\n%s", DescripationString);\r
c74c7a43 28 System.out.printf("\n%s", UsageInfoString);\r
29 System.out.printf("\n%s", DetailOfOptionString);\r
30\r
2c71f6e5 31 for (int i = 0; i < settingnum; i++) {\r
c74c7a43 32 outputSubUsageInfo(UsageString[i], UsageStringInfo[i]);\r
33 }\r
91f560c1 34 \r
35 System.out.printf("\n%s", ExampleString);\r
c74c7a43 36 }\r
37\r
38 /** \r
39 * output the usage info which bases on cmd option \r
40 * @param String str1 : the cmd option\r
41 * String str2 : the detail of cmd option\r
42 * @return no return value\r
43 **/\r
44 private static void outputSubUsageInfo(String str1, String str2) {\r
67ce7c51 45 \r
c74c7a43 46 splitString(str2);\r
67ce7c51 47 System.out.printf("\n%4s %-30s %s", "", str1, List.get(0));\r
48 for (int i=1; i<List.size(); i++){\r
49 System.out.printf("\n%4s %-30s %s", "", "", List.get(i));\r
c74c7a43 50 }\r
67ce7c51 51 List.clear();\r
c74c7a43 52 }\r
53\r
54 /** \r
55 * according to the output width, split the detail info \r
56 * @param String str :the detail info\r
57 * @return no return value\r
58 **/\r
59 private static void splitString(String str) {\r
60 int strlength = str.length();\r
61 if (strlength > MaxSrtingLength) {\r
c74c7a43 62 String[] tokens = str.split("[ ]", 0);\r
67ce7c51 63 String tempstr = null;\r
c74c7a43 64 int templength = 0;\r
c74c7a43 65 int start = 0;\r
66 int end = 0;\r
67 for (int i = 0; i < tokens.length; i++) {\r
68 if ((templength = end + tokens[i].length() + 1) < (MaxSrtingLength + start)) {\r
69 end = templength;\r
70 } else {\r
67ce7c51 71 tempstr = str.substring(start, end);\r
72 List.add(tempstr);\r
c74c7a43 73 start = end;\r
74 i = i - 1;\r
75 }\r
76 }\r
67ce7c51 77 tempstr = str.substring(start, end - 1);\r
78 List.add(tempstr);\r
79 } else {\r
80 List.add(str);\r
c74c7a43 81 }\r
82 }\r
83\r
67ce7c51 84 \r
85 private static LinkedList<String> List = new LinkedList<String>();\r
c74c7a43 86\r
87 private static final int MaxSrtingLength = 40;\r
2c71f6e5 88 \r
89 private static final int settingnum = 7;\r
90 \r
91 private static final String DescripationString = "The purpose of this tool is modifying the settings in target.txt";\r
92 \r
91f560c1 93 private static final String UsageInfoString = "Usage: ContextTool [-option1] [args] [-option2] [args] ...";\r
c74c7a43 94\r
95 private static final String DetailOfOptionString = "Where options include:";\r
91f560c1 96 \r
2c71f6e5 97 private static final String ExampleString = "Example: ContextTool -a IA32 IA64 EBC -c Tools/Conf/tools_def.txt -t DEBUG -n GCC -p EdkNt32Pkg/Nt32.fpd -m 2\n";\r
c74c7a43 98\r
99 private static final String HString = "-h";\r
100\r
2c71f6e5 101 private static final String HStringInfo = "print usage info";\r
c74c7a43 102\r
103 private static final String AString = "-a <list of Arch>";\r
104\r
105 private static final String AStringInfo = "what kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM. Multiple values can be specified on a single line, using space to separate the values.";\r
106\r
107 private static final String CString = "-c <tool_definition_file.txt>";\r
108\r
2c71f6e5 109 private static final String CStringInfo = "Assign a txt file with the relative path to WORKSPACE, which specify the tools to use for the build and must be located in the path: WORKSPACE/Tools/Conf/. If no file is specified, the default filename is \"tools_def.txt\"";\r
c74c7a43 110\r
111 private static final String NString = "-n <list of TagNames>";\r
112\r
113 private static final String NStringInfo = "Specify the TagName, such as GCC, MSFT, which are defined in the \"tool_definition_file.txt\"";\r
114\r
115 private static final String PString = "-p <*.fpd>";\r
116\r
117 private static final String PStringInfo = "Specify the WORKSPACE relative Path and Filename of platform FPD file that will be used for the build.";\r
118\r
119 private static final String TString = "-t <list of Build Targets>";\r
120\r
121 private static final String TStringInfo = "What kind of the version is the binary target, such as DEBUG, RELEASE. Multiple values can be specified on a single line, using space to separate the values.";\r
122\r
2c71f6e5 123 private static final String MString = "-m <num of Threads>";\r
124 \r
125 private static final String MStringInfo = "number should GE 0. 0 clears both MULTIPLE_THREAD and MAX_CONCURRENT_THREAD_NUMBER, others enable MULTIPLE_THREAD and set MAX_CONCURRENT_THREAD_NUMBER.";\r
126 \r
c74c7a43 127 private static final String[] UsageString = { HString, AString, CString,\r
2c71f6e5 128 NString, PString, TString, MString };\r
c74c7a43 129\r
130 private static final String[] UsageStringInfo = { HStringInfo, AStringInfo,\r
2c71f6e5 131 CStringInfo, NStringInfo, PStringInfo, TStringInfo, MStringInfo };\r
c74c7a43 132}\r