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