Make TUI optional (and update nikiroo-utils):
authorNiki Roo <niki@nikiroo.be>
Fri, 30 Jun 2017 16:54:54 +0000 (18:54 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 30 Jun 2017 16:54:54 +0000 (18:54 +0200)
- You can now use "./configure.sh --tui=no" to not include it

Makefile.base
configure.sh
libs/nikiroo-utils-1.5.1-sources.jar [moved from libs/nikiroo-utils-1.5.0-sources.jar with 74% similarity]
src/be/nikiroo/fanfix/reader/BasicReader.java

index ef0b92616fcb8a1c2b0c118bea06c326b7219e4a..e44b5d52cd5a6d09e2a6c2cad323f4aa92f24a39 100644 (file)
@@ -109,8 +109,10 @@ test-resources: resources
 libs: bin
        @[ -e bin/libs -o ! -d libs ] || echo Extracting sources from libs...
        @[ -e bin/libs -o ! -d libs ] || (cd src && for lib in ../libs/*-sources.jar ../libs/*-sources.patch.jar; do \
-               basename "$$lib"; \
-               jar xf "$$lib"; \
+               if [ "$$lib" != '../libs/*-sources.jar' -a "$$lib" != '../libs/*-sources.patch.jar' ]; then \
+                       basename "$$lib"; \
+                       jar xf "$$lib"; \
+               fi \
        done )
        @[ ! -d libs ] || touch bin/libs
 
index 42f8123945f905182436717804cbf83b26f417ef..7d87f4c6bfd4ad547c0074f0cbd596964ade29d8 100755 (executable)
@@ -4,16 +4,41 @@
 PREFIX=/usr/local
 PROGS="java javac jar make sed"
 
+CLI=be/nikiroo/fanfix/reader/CliReader
+TUI=be/nikiroo/fanfix/reader/TuiReader
+GUI=be/nikiroo/fanfix/reader/LocalReader
+
 valid=true
 while [ "$*" != "" ]; do
-       key=`echo "$1" | cut -c1-9`
-       val=`echo "$1" | cut -c10-`
+       key=`echo "$1" | cut -f1 -d=`
+       val=`echo "$1" | cut -f2 -d=`
        case "$key" in
-       --prefix=)
+       --)
+       ;;
+       --help) #               This help message
+               echo The following arguments can be used:
+               cat "$0" | grep '^\s*--' | grep '#' | while read ln; do
+                       cmd=`echo "$ln" | cut -f1 -d')'`
+                       msg=`echo "$ln" | cut -f2 -d'#'`
+                       echo "  $cmd$msg"
+               done
+       ;;
+       --prefix) #=PATH        Change the prefix to the given path
                PREFIX="$val"
        ;;
+       --cli) #=no     Disable CLI support (System.out)
+               [ "$val" = no -o "$val" = false ] && CLI=
+       ;;
+       --tui) #=no     Disable TUI support (Jexer)
+               [ "$val" = no -o "$val" = false ] && TUI=
+       ;;
+       --gui) #=no     Disable GUI support (Swing)
+               [ "$val" = no -o "$val" = false ] && GUI=
+       ;;
        *)
                echo "Unsupported parameter: '$1'" >&2
+               echo >&2
+               sh "$0" --help >&2
                valid=false
        ;;
        esac
@@ -44,6 +69,7 @@ else
 fi;
 
 echo "MAIN = be/nikiroo/fanfix/Main" > Makefile
+echo "MORE = $CLI $TUI $GUI" >> Makefile
 echo "TEST = be/nikiroo/fanfix/test/Test" >> Makefile
 echo "TEST_PARAMS = $cols $ok $ko" >> Makefile
 echo "NAME = fanfix" >> Makefile
similarity index 74%
rename from libs/nikiroo-utils-1.5.0-sources.jar
rename to libs/nikiroo-utils-1.5.1-sources.jar
index 13b8f989560c629d6a3219726454ab1a2e746f1d..786794b6334d9d21272d0395f38ec40b52f18f58 100644 (file)
Binary files a/libs/nikiroo-utils-1.5.0-sources.jar and b/libs/nikiroo-utils-1.5.1-sources.jar differ
index 74bd5d48f98000606f9d8c72c67a88ea6f80403a..7b9c98c2a6c1f0239bb460fc2fc8b7938a36a9fb 100644 (file)
@@ -15,6 +15,7 @@ import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix.supported.BasicSupport;
 import be.nikiroo.utils.Progress;
 import be.nikiroo.utils.ui.UIUtils;
+import be.nikiroo.utils.serial.SerialUtils;
 
 /**
  * The class that handles the different {@link Story} readers you can use.
@@ -31,6 +32,19 @@ public abstract class BasicReader {
                GUI,
                /** A text (UTF-8) reader with menu and text windows */
                TUI,
+               
+               ;
+               
+               public String getTypeName() {
+                       String pkg = "be.nikiroo.fanfix.reader.";
+                       switch (this) {
+                               case CLI: return pkg + "CliReader";
+                               case TUI: return pkg + "TuiReader";
+                               case GUI: return pkg + "LocalReader";
+                       }
+                       
+                       return null;
+               }
        }
 
        private static ReaderType defaultType = ReaderType.GUI;
@@ -167,19 +181,12 @@ public abstract class BasicReader {
        public static BasicReader getReader() {
                try {
                        if (defaultType != null) {
-                               switch (defaultType) {
-                               case GUI:
-                                       UIUtils.setLookAndFeel();
-                                       return new LocalReader().setType(ReaderType.GUI);
-                               case CLI:
-                                       return new CliReader().setType(ReaderType.CLI);
-                               case TUI:
-                                       return new TuiReader().setType(ReaderType.TUI);
-                               }
+                               return ((BasicReader)SerialUtils.createObject
+                                       (defaultType.getTypeName())).setType(defaultType);
                        }
-               } catch (IOException e) {
+               } catch (Exception e) {
                        Instance.syserr(new Exception("Cannot create a reader of type: "
-                                       + defaultType, e));
+                                       + defaultType + " (Not compiled in?)", e));
                }
 
                return null;