This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
/
Help.java
116 lines (101 loc) · 4.22 KB
/
Help.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright 1999-2007 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.globus.workspace.client;
import org.globus.workspace.common.Version;
import org.globus.workspace.client_core.utils.StringUtils;
import java.io.InputStream;
import java.io.IOException;
/**
* The help printing via BaseClient and commons CLI is not helpful.
*/
public class Help {
// -------------------------------------------------------------------------
// STATIC VARIABLES
// -------------------------------------------------------------------------
public static final String FIRST_LINE =
"Workspace Service CLI, " + Version.getVersion() +
" - http://www.nimbusproject.org\n";
// -------------------------------------------------------------------------
// GET HELP STRINGS
// -------------------------------------------------------------------------
public String getHelpString() throws IOException {
return this.getStringFromJar("client-help.txt");
}
public String getExtraHelpString() throws IOException {
return this.getStringFromJar("client-help-extra.txt");
}
public String getModeHelpString(AllArguments args) throws IOException {
if (args == null) {
return null;
}
final String filename;
if (args.mode_deploy) {
filename = "client-help-mode-deploy.txt";
} else if (args.mode_subscribe) {
filename = "client-help-mode-subscribe.txt";
} else if (args.mode_factoryRpQuery) {
filename = "client-help-mode-factoryrp.txt";
} else if (args.mode_destroy) {
filename = "client-help-mode-destroy.txt";
} else if (args.mode_pause) {
filename = "client-help-mode-shared1.txt";
} else if (args.mode_reboot) {
filename = "client-help-mode-shared1.txt";
} else if (args.mode_rpquery) {
filename = "client-help-mode-shared1.txt";
} else if (args.mode_shutdown) {
filename = "client-help-mode-shared1.txt";
} else if (args.mode_shutdown_save) {
filename = "client-help-mode-shutdownsave.txt";
} else if (args.mode_doneEnsemble) {
filename = "client-help-mode-done.txt";
} else if (args.mode_monitorEnsemble) {
filename = "client-help-mode-ensmonitor.txt";
} else if (args.mode_monitorContext) {
filename = "client-help-mode-ctxmonitor.txt";
} else if (args.mode_createContext) {
filename = "client-help-mode-ctxcreate.txt";
} else if (args.mode_createInjectableContext) {
filename = "client-help-mode-ctxcreate-injectable.txt";
} else if (args.mode_noMoreContextInjections) {
filename = "client-help-mode-ctx-no-more.txt";
} else if (args.mode_injectContextData) {
filename = "client-help-mode-ctxdata.txt";
} else if (args.mode_start) {
filename = "client-help-mode-shared1.txt";
} else if (args.mode_ctxPrintStatus) {
filename = "client-help-mode-ctxprintstatus.txt";
} else {
return null;
}
return this.getStringFromJar(filename);
}
private String getStringFromJar(String path) throws IOException {
InputStream is = null;
try {
is = this.getClass().getResourceAsStream(path);
if (is == null) {
return "Sorry, cannot find '" + path + "' in the jar file " +
"alongside " + this.getClass();
}
return StringUtils.getTextFileViaInputStream(is);
} finally {
if (is != null) {
is.close();
}
}
}
}