- if (args.length > 0 && args[0].equals("--tui"))
- textMode = true;
- if (args.length > 0 && args[0].equals("--gui"))
- textMode = false;
-
- Window win = null;
-
- // TODO: do not hardcode that:
- Card card = new Card(new File("/home/niki/.addressbook"), Format.Abook);
- win = new MainWindow(new ContactList(card));
- //
- List<File> files = new LinkedList<File>();
- files.add(new File("/home/niki/vcf/coworkers.vcf"));
- files.add(new File("/home/niki/vcf/oce.vcf"));
- win = new MainWindow(new FileList(files));
- //
-
- TuiLauncher.start(textMode, win);
-
- /*
- * String file = args.length > 0 ? args[0] : null; String file2 =
- * args.length > 1 ? args[1] : null;
- *
- * if (file == null) file =
- * "/home/niki/workspace/rcard/utils/CVcard/test.vcf"; if (file2 ==
- * null) file2 = "/home/niki/workspace/rcard/utils/CVcard/test.abook";
- *
- * Card card = new Card(new File(file), Format.VCard21);
- * System.out.println(card.toString());
- *
- * System.out.println("\n -- PINE -- \n");
- *
- * card = new Card(new File(file2), Format.Abook);
- * System.out.println(card.toString(Format.Abook));
- */
+ boolean noMoreParams = false;
+ boolean filesTried = false;
+
+ // get the "system default" language to help translate the --help
+ // message if needed
+ String language = null;
+ transService = new Trans(language);
+
+ List<String> files = new LinkedList<String>();
+ for (int index = 0; index < args.length; index++) {
+ String arg = args[index];
+ if (!noMoreParams && arg.equals("--")) {
+ noMoreParams = true;
+ } else if (!noMoreParams && arg.equals("--help")) {
+ System.out
+ .println("TODO: implement some help text.\n"
+ + "Usable switches:\n"
+ + "\t--: stop looking for switches\n"
+ + "\t--help: this here thingy\n"
+ + "\t--lang LANGUAGE: choose the language, for instance en_GB\n"
+ + "\t--tui: force pure text mode even if swing treminal is available\n"
+ + "\t--gui: force swing terminal mode\n"
+ + "\t--noutf: force non-utf8 mode if you need it\n"
+ + "\t--config DIRECTORY: force the given directory as a CONFIG_DIR\n"
+ + "everyhing else is either a file to open or a directory to open\n"
+ + "(we will only open 1st level files in given directories)\n"
+ + "('jvcard://hostname:8888/file' links -- or without 'file' -- are also ok)\n");
+ return;
+ } else if (!noMoreParams && arg.equals("--tui")) {
+ textMode = true;
+ } else if (!noMoreParams && arg.equals("--gui")) {
+ textMode = false;
+ } else if (!noMoreParams && arg.equals("--noutf")) {
+ UiColors.getInstance().setUnicode(false);
+ } else if (!noMoreParams && arg.equals("--lang")) {
+ index++;
+ if (index < args.length)
+ language = args[index];
+ transService = new Trans(language);
+ } else if (!noMoreParams && arg.equals("--config")) {
+ index++;
+ if (index < args.length) {
+ Bundles.setDirectory(args[index]);
+ transService = new Trans(language);
+ }
+ } else {
+ filesTried = true;
+ files.addAll(open(arg));
+ }
+ }
+
+ if (UiColors.getInstance().isUnicode()) {
+ utf8();
+ }
+
+ if (files.size() == 0) {
+ if (filesTried) {
+ System.exit(1);
+ return;
+ }
+
+ files.addAll(open("."));
+ }
+
+ // TODO error case when no file
+
+ Window win = new MainWindow(new FileList(files));
+
+ try {
+ TuiLauncher.start(textMode, win);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ System.exit(2);
+ }