115
115
Herold converter = new Herold();
117
FileOption optProfile = (FileOption) options.getOption("profile");
117
StringOption optProfile = (StringOption) options
118
.getOption("profile");
119
File profileFile = findProfile(optProfile);
120
122
TrafoScriptManager mgr = new TrafoScriptManager();
121
if (optProfile.isUnset() == false) {
122
File profileFile = optProfile.getValue();
123
script = mgr.parseScript(profileFile);
124
logger.info(String.format("Using profile file %s.",
125
profileFile.getAbsolutePath()));
127
script = new Script();
128
logger.warn("No profile file was found!");
123
script = mgr.parseScript(profileFile);
124
logger.info(String.format("Using profile file %s.",
125
profileFile.getAbsolutePath()));
131
127
if (logger.isTraceEnabled()) {
132
128
StringWriter buffer = new StringWriter();
137
133
File outFile = converter.processCommandLineOptions(options, script);
134
logger.info(String.format("Output file is %s.", outFile.getPath()));
138
135
script.setOutputFile(outFile);
139
136
script.setInputFile(optIn.getValue());
184
private static File findProfile(StringOption optProfile)
185
throws FileNotFoundException {
187
String profileName = "default.her";
189
if (optProfile.isUnset() == false) {
190
profileName = optProfile.getValue();
193
if (profileName == null || profileName.trim().length() == 0) {
194
profileName = "default.her";
197
File profile = new File(profileName);
199
if (profile.exists() == true) {
203
String homePath = System.getProperty("herold.home");
205
if (homePath != null) {
207
File homeDir = new File(homePath);
209
if (homeDir.exists() == false) {
210
throw new FileNotFoundException(String.format(
211
"Home directory %s does not exist!", homePath));
214
File profilesDir = new File(homeDir, "profiles");
216
if (profilesDir.exists() == false) {
217
throw new FileNotFoundException(String.format(
218
"Profiles directory %s does not exist!",
219
profilesDir.getAbsolutePath()));
222
File file = new File(profilesDir, profileName);
224
if (file.exists() == true) {
228
file = new File(profilesDir, profileName + ".her");
230
if (file.exists() == true) {
235
throw new FileNotFoundException(String.format(
236
"Profile %s does not exist!", profileName));
239
private static void exit(int exitCode) {
241
Herold.exitCode = exitCode;
184
243
if (systemExitEnabled == true) {
185
244
System.exit(exitCode);
196
255
OptionList options = new OptionList(args);
199
258
bopt = new BooleanOption(DbtConstants.SECTION_DOCBOOK.toLowerCase()
200
259
+ "-" + DbtConstants.PARAM_DOCBOOK_ADD_INDEX, "x");
201
260
bopt.setValue(false);
202
261
options.add(bopt);
204
// destination-encoding
205
264
sopt = new StringOption(DbtConstants.SECTION_DOCBOOK.toLowerCase()
206
+ "-" + DbtConstants.PARAM_DOCBOOK_DESTINATION_ENCODING, "d");
265
+ "-" + DbtConstants.PARAM_DOCBOOK_ENCODING, "d");
207
266
sopt.setDefault("UTF-8");
208
267
options.add(sopt);
217
276
selopt = new SelectOption(DbtConstants.SECTION_DOCBOOK.toLowerCase()
218
277
+ "-" + DbtConstants.PARAM_DOCBOOK_DOCUMENT_ELEMENT, "r");
220
String[] optv2 = { "article", "book", "reference" };
279
String[] optv2 = { "article", "book", "reference", "section" };
221
280
selopt.setList(optv2);
222
281
selopt.setDefault("article");
223
282
options.add(selopt);
251
310
optOut = new FileOption("out", "o");
252
311
options.add(optOut);
254
FileOption optProfile = new FileOption("profile", "p");
255
optProfile.isExisting(true);
313
StringOption optProfile = new StringOption("profile", "p");
256
314
options.add(optProfile);
273
331
URL url = ResourceServices
274
332
.getResourceAsUrl("/org/dbdoclet/herold/COPYING");
276
BufferedReader reader = new BufferedReader(new InputStreamReader(
278
String line = reader.readLine();
280
while (line != null) {
282
line = reader.readLine();
335
BufferedReader reader = new BufferedReader(new InputStreamReader(
337
String line = reader.readLine();
339
while (line != null) {
341
line = reader.readLine();
346
logger.fatal("Can't find resource for license!");
288
350
private static void println(String str) {
340
402
script.selectSection(DbtConstants.SECTION_DOCBOOK);
341
403
name = StringServices.cutPrefix(name,
342
404
DbtConstants.SECTION_DOCBOOK.toLowerCase());
343
406
} else if (name.startsWith(DbtConstants.SECTION_HTML.toLowerCase())) {
344
407
script.selectSection(DbtConstants.SECTION_HTML);
345
408
name = StringServices.cutPrefix(name,
352
415
switch (option.getType()) {
355
script.addBoolParam(name, (Boolean) option.getValue());
418
script.setBoolParam(name, (Boolean) option.getValue());
359
script.addTextParam(name, option.getValue().toString());
422
script.setTextParam(name, option.getValue().toString());