1 package be
.nikiroo
.fanfix
;
4 import java
.io
.IOException
;
5 import java
.net
.MalformedURLException
;
7 import java
.util
.ArrayList
;
10 import javax
.net
.ssl
.SSLException
;
12 import be
.nikiroo
.fanfix
.bundles
.Config
;
13 import be
.nikiroo
.fanfix
.bundles
.StringId
;
14 import be
.nikiroo
.fanfix
.data
.Chapter
;
15 import be
.nikiroo
.fanfix
.data
.MetaData
;
16 import be
.nikiroo
.fanfix
.data
.Story
;
17 import be
.nikiroo
.fanfix
.library
.BasicLibrary
;
18 import be
.nikiroo
.fanfix
.library
.CacheLibrary
;
19 import be
.nikiroo
.fanfix
.library
.LocalLibrary
;
20 import be
.nikiroo
.fanfix
.library
.RemoteLibrary
;
21 import be
.nikiroo
.fanfix
.library
.RemoteLibraryServer
;
22 import be
.nikiroo
.fanfix
.library
.WebLibraryServer
;
23 import be
.nikiroo
.fanfix
.output
.BasicOutput
;
24 import be
.nikiroo
.fanfix
.output
.BasicOutput
.OutputType
;
25 import be
.nikiroo
.fanfix
.reader
.BasicReader
;
26 import be
.nikiroo
.fanfix
.reader
.CliReader
;
27 import be
.nikiroo
.fanfix
.searchable
.BasicSearchable
;
28 import be
.nikiroo
.fanfix
.supported
.BasicSupport
;
29 import be
.nikiroo
.fanfix
.supported
.SupportType
;
30 import be
.nikiroo
.utils
.Progress
;
31 import be
.nikiroo
.utils
.Version
;
32 import be
.nikiroo
.utils
.VersionCheck
;
35 * Main program entry point.
40 private enum MainAction
{
41 IMPORT
, EXPORT
, CONVERT
, READ
, READ_URL
, LIST
, HELP
, START
, VERSION
, SERVER
, STOP_SERVER
, REMOTE
, SET_SOURCE
, SET_TITLE
, SET_AUTHOR
, SEARCH
, SEARCH_TAG
45 * Main program entry point.
47 * Known environment variables:
49 * <li>NOUTF: if set to 1 or 'true', the program will prefer non-unicode
50 * {@link String}s when possible</li>
51 * <li>CONFIG_DIR: a path where to look for the <tt>.properties</tt> files
52 * before taking the usual ones; they will also be saved/updated into this
53 * path when the program starts</li>
54 * <li>DEBUG: if set to 1 or 'true', the program will override the DEBUG_ERR
55 * configuration value with 'true'</li>
59 * <li>--import [URL]: import into library</li>
60 * <li>--export [id] [output_type] [target]: export story to target</li>
61 * <li>--convert [URL] [output_type] [target] (+info): convert URL into
63 * <li>--read [id] ([chapter number]): read the given story from the library
65 * <li>--read-url [URL] ([chapter number]): convert on the fly and read the
66 * story, without saving it</li>
67 * <li>--search: list the supported websites (where)</li>
68 * <li>--search [where] [keywords] (page [page]) (item [item]): search on
69 * the supported website and display the given results page of stories it
70 * found, or the story details if asked</li>
71 * <li>--search-tag [where]: list all the tags supported by this website</li>
72 * <li>--search-tag [index 1]... (page [page]) (item [item]): search for the
73 * given stories or subtags, tag by tag, and display information about a
74 * specific page of results or about a specific item if requested</li>
75 * <li>--list ([type]): list the stories present in the library</li>
76 * <li>--set-source [id] [new source]: change the source of the given story</li>
77 * <li>--set-title [id] [new title]: change the title of the given story</li>
78 * <li>--set-author [id] [new author]: change the author of the given story</li>
79 * <li>--version: get the version of the program</li>
80 * <li>--server: start the server mode (see config file for parameters)</li>
81 * <li>--stop-server: stop the running server on this port if any</li>
82 * <li>--remote [key] [host] [port]: use the given remote library</li>
86 * see method description
88 public static void main(String
[] args
) {
89 new Main().start(args
);
93 * Start the default handling for the application.
95 * If specific actions were asked (with correct parameters), they will be
96 * forwarded to the different protected methods that you can override.
98 * At the end of the method, {@link Main#exit(int)} will be called; by
99 * default, it calls {@link System#exit(int)} if the status is not 0.
102 * the arguments received from the system
104 public void start(String
[] args
) {
105 // Only one line, but very important:
108 String urlString
= null;
110 String sourceString
= null;
111 String titleString
= null;
112 String authorString
= null;
113 String chapString
= null;
114 String target
= null;
116 MainAction action
= MainAction
.START
;
117 Boolean plusInfo
= null;
120 SupportType searchOn
= null;
121 String search
= null;
122 List
<Integer
> tags
= new ArrayList
<Integer
>();
126 boolean noMoreActions
= false;
129 for (int i
= 0; exitCode
== 0 && i
< args
.length
; i
++) {
133 // Action (--) handling:
134 if (!noMoreActions
&& args
[i
].startsWith("--")) {
135 if (args
[i
].equals("--")) {
136 noMoreActions
= true;
139 action
= MainAction
.valueOf(args
[i
].substring(2)
140 .toUpperCase().replace("-", "_"));
141 } catch (Exception e
) {
142 Instance
.getInstance().getTraceHandler()
143 .error(new IllegalArgumentException("Unknown action: " + args
[i
], e
));
153 if (urlString
== null) {
162 } else if (sourceString
== null) {
163 sourceString
= args
[i
];
164 } else if (target
== null) {
171 if (urlString
== null) {
173 } else if (sourceString
== null) {
174 sourceString
= args
[i
];
175 } else if (target
== null) {
177 } else if (plusInfo
== null) {
178 if ("+info".equals(args
[i
])) {
188 if (sourceString
== null) {
189 sourceString
= args
[i
];
197 } else if (sourceString
== null) {
198 sourceString
= args
[i
];
206 } else if (sourceString
== null) {
207 titleString
= args
[i
];
215 } else if (sourceString
== null) {
216 authorString
= args
[i
];
224 } else if (chapString
== null) {
225 chapString
= args
[i
];
231 if (urlString
== null) {
233 } else if (chapString
== null) {
234 chapString
= args
[i
];
240 if (searchOn
== null) {
241 searchOn
= SupportType
.valueOfAllOkUC(args
[i
]);
243 if (searchOn
== null) {
244 Instance
.getInstance().getTraceHandler().error("Website not known: <" + args
[i
] + ">");
249 if (BasicSearchable
.getSearchable(searchOn
) == null) {
250 Instance
.getInstance().getTraceHandler().error("Website not supported: " + searchOn
);
254 } else if (search
== null) {
256 } else if (page
!= null && page
== -1) {
258 page
= Integer
.parseInt(args
[i
]);
259 } catch (Exception e
) {
262 } else if (item
!= null && item
== -1) {
264 item
= Integer
.parseInt(args
[i
]);
265 } catch (Exception e
) {
268 } else if (page
== null || item
== null) {
269 if (page
== null && "page".equals(args
[i
])) {
271 } else if (item
== null && "item".equals(args
[i
])) {
281 if (searchOn
== null) {
282 searchOn
= SupportType
.valueOfAllOkUC(args
[i
]);
284 if (searchOn
== null) {
285 Instance
.getInstance().getTraceHandler().error("Website not known: <" + args
[i
] + ">");
289 if (BasicSearchable
.getSearchable(searchOn
) == null) {
290 Instance
.getInstance().getTraceHandler().error("Website not supported: " + searchOn
);
293 } else if (page
== null && item
== null) {
294 if ("page".equals(args
[i
])) {
296 } else if ("item".equals(args
[i
])) {
300 int index
= Integer
.parseInt(args
[i
]);
302 } catch (NumberFormatException e
) {
303 Instance
.getInstance().getTraceHandler().error("Invalid tag index: " + args
[i
]);
307 } else if (page
!= null && page
== -1) {
309 page
= Integer
.parseInt(args
[i
]);
310 } catch (Exception e
) {
313 } else if (item
!= null && item
== -1) {
315 item
= Integer
.parseInt(args
[i
]);
316 } catch (Exception e
) {
319 } else if (page
== null || item
== null) {
320 if (page
== null && "page".equals(args
[i
])) {
322 } else if (item
== null && "item".equals(args
[i
])) {
335 exitCode
= 255; // not supposed to be selected by user
338 exitCode
= 255; // no arguments for this option
341 exitCode
= 255; // no arguments for this option
344 exitCode
= 255; // no arguments for this option
349 } else if (host
== null) {
351 } else if (port
== null) {
352 port
= Integer
.parseInt(args
[i
]);
354 BasicLibrary lib
= new RemoteLibrary(key
, host
, port
);
355 lib
= new CacheLibrary(
356 Instance
.getInstance().getRemoteDir(host
), lib
,
357 Instance
.getInstance().getUiConfig());
359 Instance
.getInstance().setLibrary(lib
);
361 action
= MainAction
.START
;
369 final Progress mainProgress
= new Progress(0, 80);
370 mainProgress
.addProgressListener(new Progress
.ProgressListener() {
371 private int current
= mainProgress
.getMin();
374 public void progress(Progress progress
, String name
) {
375 int diff
= progress
.getProgress() - current
;
381 StringBuilder builder
= new StringBuilder();
382 for (int i
= 0; i
< diff
; i
++) {
386 System
.err
.print(builder
.toString());
388 if (progress
.isDone()) {
389 System
.err
.println("");
393 Progress pg
= new Progress();
394 mainProgress
.addProgress(pg
, mainProgress
.getMax());
396 VersionCheck updates
= checkUpdates();
401 if (updates
!= null) {
402 // we consider it read
403 Instance
.getInstance().setVersionChecked();
407 exitCode
= imprt(BasicReader
.getUrl(urlString
), pg
);
408 } catch (MalformedURLException e
) {
409 Instance
.getInstance().getTraceHandler().error(e
);
415 if (updates
!= null) {
416 // we consider it read
417 Instance
.getInstance().setVersionChecked();
420 OutputType exportType
= OutputType
.valueOfNullOkUC(sourceString
, null);
421 if (exportType
== null) {
422 Instance
.getInstance().getTraceHandler().error(new Exception(trans(StringId
.OUTPUT_DESC
, sourceString
)));
427 exitCode
= export(luid
, exportType
, target
, pg
);
431 if (updates
!= null) {
432 // we consider it read
433 Instance
.getInstance().setVersionChecked();
436 OutputType convertType
= OutputType
.valueOfAllOkUC(sourceString
, null);
437 if (convertType
== null) {
438 Instance
.getInstance().getTraceHandler()
439 .error(new IOException(trans(StringId
.ERR_BAD_OUTPUT_TYPE
, sourceString
)));
445 exitCode
= convert(urlString
, convertType
, target
,
446 plusInfo
== null ?
false : plusInfo
, pg
);
450 exitCode
= list(sourceString
);
454 Instance
.getInstance().getLibrary().changeSource(luid
, sourceString
, pg
);
455 } catch (IOException e1
) {
456 Instance
.getInstance().getTraceHandler().error(e1
);
462 Instance
.getInstance().getLibrary().changeTitle(luid
, titleString
, pg
);
463 } catch (IOException e1
) {
464 Instance
.getInstance().getTraceHandler().error(e1
);
470 Instance
.getInstance().getLibrary().changeAuthor(luid
, authorString
, pg
);
471 } catch (IOException e1
) {
472 Instance
.getInstance().getTraceHandler().error(e1
);
477 if (luid
== null || luid
.isEmpty()) {
485 if (chapString
!= null) {
487 chap
= Integer
.parseInt(chapString
);
488 } catch (NumberFormatException e
) {
489 Instance
.getInstance().getTraceHandler().error(new IOException(
490 "Chapter number cannot be parsed: " + chapString
, e
));
496 BasicLibrary lib
= Instance
.getInstance().getLibrary();
497 exitCode
= read(lib
.getStory(luid
, null), chap
);
498 } catch (IOException e
) {
499 Instance
.getInstance().getTraceHandler()
500 .error(new IOException("Failed to read book", e
));
506 if (urlString
== null || urlString
.isEmpty()) {
514 if (chapString
!= null) {
516 chap
= Integer
.parseInt(chapString
);
517 } catch (NumberFormatException e
) {
518 Instance
.getInstance().getTraceHandler().error(new IOException(
519 "Chapter number cannot be parsed: " + chapString
, e
));
525 BasicSupport support
= BasicSupport
526 .getSupport(BasicReader
.getUrl(urlString
));
527 if (support
== null) {
528 Instance
.getInstance().getTraceHandler()
529 .error("URL not supported: " + urlString
);
534 exitCode
= read(support
.process(null), chap
);
535 } catch (IOException e
) {
536 Instance
.getInstance().getTraceHandler()
537 .error(new IOException("Failed to read book", e
));
543 page
= page
== null ?
1 : page
;
545 Instance
.getInstance().getTraceHandler().error("Incorrect page number");
550 item
= item
== null ?
0 : item
;
552 Instance
.getInstance().getTraceHandler().error("Incorrect item number");
557 if (searchOn
== null) {
560 } catch (IOException e
) {
561 Instance
.getInstance().getTraceHandler().error(e
);
564 } else if (search
!= null) {
566 searchKeywords(searchOn
, search
, page
, item
);
567 } catch (IOException e
) {
568 Instance
.getInstance().getTraceHandler().error(e
);
577 if (searchOn
== null) {
582 page
= page
== null ?
1 : page
;
584 Instance
.getInstance().getTraceHandler().error("Incorrect page number");
589 item
= item
== null ?
0 : item
;
591 Instance
.getInstance().getTraceHandler().error("Incorrect item number");
597 searchTags(searchOn
, page
, item
,
598 tags
.toArray(new Integer
[] {}));
599 } catch (IOException e
) {
600 Instance
.getInstance().getTraceHandler().error(e
);
609 if (updates
!= null) {
610 // we consider it read
611 Instance
.getInstance().setVersionChecked();
615 .println(String
.format("Fanfix version %s"
616 + "%nhttps://github.com/nikiroo/fanfix/"
617 + "%n\tWritten by Nikiroo",
618 Version
.getCurrentVersion()));
623 } catch (IOException e
) {
624 Instance
.getInstance().getTraceHandler().error(e
);
631 } catch (IOException e
) {
632 Instance
.getInstance().getTraceHandler().error(e
);
637 // Can be given via "--remote XX XX XX"
639 key
= Instance
.getInstance().getConfig().getString(Config
.SERVER_KEY
);
641 port
= Instance
.getInstance().getConfig().getInteger(Config
.SERVER_PORT
);
644 System
.err
.println("No port given nor configured in the config file");
649 stopServer(key
, host
, port
);
650 } catch (SSLException e
) {
651 Instance
.getInstance().getTraceHandler().error(
652 "Bad access key for remote library");
654 } catch (IOException e
) {
655 Instance
.getInstance().getTraceHandler().error(e
);
661 exitCode
= 255; // should not be reachable (REMOTE -> START)
667 Instance
.getInstance().getTempFiles().close();
668 } catch (IOException e
) {
669 Instance
.getInstance().getTraceHandler().error(new IOException(
670 "Cannot dispose of the temporary files", e
));
673 if (exitCode
== 255) {
681 * A normal invocation of the program (without parameters or at least
682 * without "action" parameters).
684 * You will probably want to override that one if you offer a user
687 * @throws IOException
688 * in case of I/O error
690 protected void start() throws IOException
{
691 new CliReader().listBooks(null);
695 * Will check if updates are available, synchronously.
697 * For this, it will simply forward the call to
698 * {@link Main#checkUpdates(String)} with a value of "nikiroo/fanfix".
700 * You may want to override it so you call the forward method with the right
701 * parameters (or also if you want it to be asynchronous).
703 * @return the newer version information or NULL if nothing new
705 protected VersionCheck
checkUpdates() {
706 return checkUpdates("nikiroo/fanfix");
710 * Will check if updates are available on a specific GitHub project.
712 * Will be called by {@link Main#checkUpdates()}, but if you override that
713 * one you mall call it with another project.
715 * @param githubProject
716 * the GitHub project, for instance "nikiroo/fanfix"
718 * @return the newer version information or NULL if nothing new
720 protected VersionCheck
checkUpdates(String githubProject
) {
722 VersionCheck updates
= VersionCheck
.check(githubProject
,
723 Instance
.getInstance().getTrans().getLocale());
724 if (updates
.isNewVersionAvailable()) {
725 notifyUpdates(updates
);
728 } catch (IOException e
) {
729 // Maybe no internet. Do not report any update.
736 * Notify the user about available updates.
738 * Will only be called when a version is available.
740 * Note that you can call {@link Instance#setVersionChecked()} on it if the
741 * user has read the information (by default, it is marked read only on
742 * certain other actions).
745 * the new version information
747 protected void notifyUpdates(VersionCheck updates
) {
748 // Sent to syserr so not to cause problem if one tries to capture a
749 // story content in text mode
751 "A new version of the program is available at https://github.com/nikiroo/fanfix/releases");
752 System
.err
.println("");
753 for (Version v
: updates
.getNewer()) {
754 System
.err
.println("\tVersion " + v
);
755 System
.err
.println("\t-------------");
756 System
.err
.println("");
757 for (String it
: updates
.getChanges().get(v
)) {
758 System
.err
.println("\t- " + it
);
760 System
.err
.println("");
765 * Import the given resource into the {@link LocalLibrary}.
768 * the resource to import
770 * the optional progress reporter
772 * @return the exit return code (0 = success)
774 protected static int imprt(URL url
, Progress pg
) {
776 MetaData meta
= Instance
.getInstance().getLibrary().imprt(url
, pg
);
777 System
.out
.println(meta
.getLuid() + ": \"" + meta
.getTitle() + "\" imported.");
778 } catch (IOException e
) {
779 Instance
.getInstance().getTraceHandler().error(e
);
787 * Export the {@link Story} from the {@link LocalLibrary} to the given
793 * the {@link OutputType} to use
797 * the optional progress reporter
799 * @return the exit return code (0 = success)
801 protected static int export(String luid
, OutputType type
, String target
,
804 Instance
.getInstance().getLibrary().export(luid
, type
, target
, pg
);
805 } catch (IOException e
) {
806 Instance
.getInstance().getTraceHandler().error(e
);
814 * List the stories of the given source from the {@link LocalLibrary}
815 * (unless NULL is passed, in which case all stories will be listed).
818 * the source to list the known stories of, or NULL to list all
821 * @return the exit return code (0 = success)
823 protected int list(String source
) {
825 new CliReader().listBooks(source
);
826 } catch (IOException e
) {
827 Instance
.getInstance().getTraceHandler().error(e
);
835 * Start the current reader for this {@link Story}.
840 * which {@link Chapter} to read (starting at 1), or NULL to get
841 * the {@link Story} description
843 * @return the exit return code (0 = success)
845 protected int read(Story story
, Integer chap
) {
849 new CliReader().listChapters(story
);
851 new CliReader().printChapter(story
, chap
);
853 } catch (IOException e
) {
854 Instance
.getInstance().getTraceHandler()
855 .error(new IOException("Failed to read book", e
));
859 Instance
.getInstance().getTraceHandler()
860 .error("Cannot find book: " + story
);
868 * Convert the {@link Story} into another format.
871 * the source {@link Story} to convert
873 * the {@link OutputType} to convert to
877 * TRUE to also export the cover and info file, even if the given
878 * {@link OutputType} does not usually save them
880 * the optional progress reporter
882 * @return the exit return code (0 = success)
884 protected int convert(String urlString
, OutputType type
,
885 String target
, boolean infoCover
, Progress pg
) {
888 Instance
.getInstance().getTraceHandler().trace("Convert: " + urlString
);
889 String sourceName
= urlString
;
891 URL source
= BasicReader
.getUrl(urlString
);
892 sourceName
= source
.toString();
893 if (sourceName
.startsWith("file://")) {
894 sourceName
= sourceName
.substring("file://".length());
898 BasicSupport support
= BasicSupport
.getSupport(source
);
900 if (support
!= null) {
901 Instance
.getInstance().getTraceHandler()
902 .trace("Support found: " + support
.getClass());
903 Progress pgIn
= new Progress();
904 Progress pgOut
= new Progress();
907 pg
.addProgress(pgIn
, 1);
908 pg
.addProgress(pgOut
, 1);
911 Story story
= support
.process(pgIn
);
913 target
= new File(target
).getAbsolutePath();
914 BasicOutput
.getOutput(type
, infoCover
, infoCover
)
915 .process(story
, target
, pgOut
);
916 } catch (IOException e
) {
917 Instance
.getInstance().getTraceHandler()
918 .error(new IOException(
919 trans(StringId
.ERR_SAVING
, target
), e
));
923 Instance
.getInstance().getTraceHandler()
924 .error(new IOException(
925 trans(StringId
.ERR_NOT_SUPPORTED
, source
)));
929 } catch (IOException e
) {
930 Instance
.getInstance().getTraceHandler().error(new IOException(
931 trans(StringId
.ERR_LOADING
, sourceName
), e
));
934 } catch (MalformedURLException e
) {
935 Instance
.getInstance().getTraceHandler().error(new IOException(trans(StringId
.ERR_BAD_URL
, sourceName
), e
));
943 * Display the correct syntax of the program to the user to stdout, or an
944 * error message if the syntax used was wrong on stderr.
947 * TRUE to show the syntax help, FALSE to show "syntax error"
949 protected void syntax(boolean showHelp
) {
951 StringBuilder builder
= new StringBuilder();
952 for (SupportType type
: SupportType
.values()) {
953 builder
.append(trans(StringId
.ERR_SYNTAX_TYPE
, type
.toString(),
955 builder
.append('\n');
958 String typesIn
= builder
.toString();
959 builder
.setLength(0);
961 for (OutputType type
: OutputType
.values()) {
962 builder
.append(trans(StringId
.ERR_SYNTAX_TYPE
, type
.toString(),
963 type
.getDesc(true)));
964 builder
.append('\n');
967 String typesOut
= builder
.toString();
969 System
.out
.println(trans(StringId
.HELP_SYNTAX
, typesIn
, typesOut
));
971 System
.err
.println(trans(StringId
.ERR_SYNTAX
));
976 * Starts a search operation (i.e., list the available web sites we can
979 * @throws IOException
980 * in case of I/O errors
982 protected void search() throws IOException
{
983 new CliReader().listSearchables();
987 * Search for books by keywords on the given supported web site.
990 * the web site to search on
992 * the keyword to look for
994 * the page of results to get, or 0 to inquire about the number
997 * the index of the book we are interested by, or 0 to query
998 * about how many books are in that page of results
1000 * @throws IOException
1001 * in case of I/O error
1003 protected void searchKeywords(SupportType searchOn
, String search
,
1004 int page
, Integer item
) throws IOException
{
1005 new CliReader().searchBooksByKeyword(searchOn
, search
, page
, item
);
1009 * Search for books by tags on the given supported web site.
1012 * the web site to search on
1014 * the page of results to get, or 0 to inquire about the number
1017 * the index of the book we are interested by, or 0 to query
1018 * about how many books are in that page of results
1020 * the tags to look for
1022 * @throws IOException
1023 * in case of I/O error
1025 protected void searchTags(SupportType searchOn
, Integer page
, Integer item
,
1026 Integer
[] tags
) throws IOException
{
1027 new CliReader().searchBooksByTag(searchOn
, page
, item
, tags
);
1031 * Start a Fanfix server.
1033 * @throws IOException
1034 * in case of I/O errors
1035 * @throws SSLException
1036 * when the key was not accepted
1038 private void startServer() throws IOException
{
1039 String mode
= Instance
.getInstance().getConfig()
1040 .getString(Config
.SERVER_MODE
, "fanfix");
1041 if (mode
.equals("fanfix")) {
1042 RemoteLibraryServer server
= new RemoteLibraryServer();
1043 server
.setTraceHandler(Instance
.getInstance().getTraceHandler());
1045 } else if (mode
.equals("http")) {
1046 WebLibraryServer server
= new WebLibraryServer(false);
1047 server
.setTraceHandler(Instance
.getInstance().getTraceHandler());
1049 } else if (mode
.equals("https")) {
1050 WebLibraryServer server
= new WebLibraryServer(true);
1051 server
.setTraceHandler(Instance
.getInstance().getTraceHandler());
1054 throw new IOException("Unknown server mode: " + mode
);
1059 * Stop a running Fanfix server.
1062 * the key to contact the Fanfix server
1064 * the host on which it runs (NULL means localhost)
1066 * the port on which it runs
1068 * @throws IOException
1069 * in case of I/O errors
1070 * @throws SSLException
1071 * when the key was not accepted
1073 private void stopServer(
1074 String key
, String host
, Integer port
)
1075 throws IOException
, SSLException
{
1076 new RemoteLibrary(key
, host
, port
).exit();
1080 * We are done and ready to exit.
1082 * By default, it will call {@link System#exit(int)} if the status is not 0.
1087 protected void exit(int status
) {
1089 System
.exit(status
);
1094 * Simple shortcut method to call {link Instance#getTrans()#getString()}.
1097 * the ID to translate
1099 * @return the translated result
1101 static private String
trans(StringId id
, Object
... params
) {
1102 return Instance
.getInstance().getTrans().getString(id
, params
);