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