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