]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/ContextTool/org/tianocore/context/HelpInfo.java
add the copyright info and the file description.
[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
16public class HelpInfo {\r
17\r
18 \r
19 /** \r
20 * output the tools usage guide\r
21 * @param no input parameter\r
22 * @return no return value\r
23 **/\r
24 public static void outputUsageInfo() {\r
25 System.out.printf("\n%s", UsageInfoString);\r
26 System.out.printf("\n%s", DetailOfOptionString);\r
27\r
28 for (int i = 0; i < 6; i++) {\r
29 outputSubUsageInfo(UsageString[i], UsageStringInfo[i]);\r
30 }\r
31 }\r
32\r
33 /** \r
34 * output the usage info which bases on cmd option \r
35 * @param String str1 : the cmd option\r
36 * String str2 : the detail of cmd option\r
37 * @return no return value\r
38 **/\r
39 private static void outputSubUsageInfo(String str1, String str2) {\r
40 splitString(str2);\r
41 if (substrnum > 0) {\r
42 System.out.printf("\n%4s %-30s %s", "", str1, substr[0]);\r
43 for (int i = 1; i < substrnum; i++) {\r
44 if (substr[i] != null)\r
45 System.out.printf("\n%4s %-30s %s", "", "", substr[i]);\r
46 }\r
47 substrnum = 0;\r
48 } else {\r
49 System.out.printf("\n%4s %-30s %s", "", str1, str2);\r
50 }\r
51 }\r
52\r
53 /** \r
54 * according to the output width, split the detail info \r
55 * @param String str :the detail info\r
56 * @return no return value\r
57 **/\r
58 private static void splitString(String str) {\r
59 int strlength = str.length();\r
60 if (strlength > MaxSrtingLength) {\r
61 \r
62 //we should modify the array to list, for it is strange to + 2\r
63 substrnum = strlength / MaxSrtingLength + 2;\r
64 String[] tokens = str.split("[ ]", 0);\r
65 substr = new String[substrnum];\r
66 int templength = 0;\r
67 int j = 0;\r
68 int start = 0;\r
69 int end = 0;\r
70 for (int i = 0; i < tokens.length; i++) {\r
71 if ((templength = end + tokens[i].length() + 1) < (MaxSrtingLength + start)) {\r
72 end = templength;\r
73 } else {\r
74 substr[j++] = str.substring(start, end);\r
75 start = end;\r
76 i = i - 1;\r
77 }\r
78 }\r
79 substr[j] = str.substring(start, end - 1);\r
80 }\r
81 }\r
82\r
83 private static String[] substr = null;\r
84\r
85 private static int substrnum = 0;\r
86\r
87 private static final int MaxSrtingLength = 40;\r
88\r
89 private static final String UsageInfoString = "Usage: context [-option1] [args] [-option2] [args] ...";\r
90\r
91 private static final String DetailOfOptionString = "Where options include:";\r
92\r
93 private static final String HString = "-h";\r
94\r
95 private static final String HStringInfo = "print this help message";\r
96\r
97 private static final String AString = "-a <list of Arch>";\r
98\r
99 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
100\r
101 private static final String CString = "-c <tool_definition_file.txt>";\r
102\r
103 private static final String CStringInfo = "Assign a txt file, 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
104\r
105 private static final String NString = "-n <list of TagNames>";\r
106\r
107 private static final String NStringInfo = "Specify the TagName, such as GCC, MSFT, which are defined in the \"tool_definition_file.txt\"";\r
108\r
109 private static final String PString = "-p <*.fpd>";\r
110\r
111 private static final String PStringInfo = "Specify the WORKSPACE relative Path and Filename of platform FPD file that will be used for the build.";\r
112\r
113 private static final String TString = "-t <list of Build Targets>";\r
114\r
115 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
116\r
117 private static final String[] UsageString = { HString, AString, CString,\r
118 NString, PString, TString };\r
119\r
120 private static final String[] UsageStringInfo = { HStringInfo, AStringInfo,\r
121 CStringInfo, NStringInfo, PStringInfo, TStringInfo };\r
122}\r