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