From: Niki Roo Date: Fri, 30 Jun 2017 16:54:54 +0000 (+0200) Subject: Make TUI optional (and update nikiroo-utils): X-Git-Tag: fanfix-1.6.0~29 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=9119671d3774c0b74ce8661b5262ff14e6bfb010;p=fanfix.git Make TUI optional (and update nikiroo-utils): - You can now use "./configure.sh --tui=no" to not include it --- diff --git a/Makefile.base b/Makefile.base index ef0b926..e44b5d5 100644 --- a/Makefile.base +++ b/Makefile.base @@ -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 diff --git a/configure.sh b/configure.sh index 42f8123..7d87f4c 100755 --- a/configure.sh +++ b/configure.sh @@ -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 diff --git a/libs/nikiroo-utils-1.5.0-sources.jar b/libs/nikiroo-utils-1.5.1-sources.jar similarity index 74% rename from libs/nikiroo-utils-1.5.0-sources.jar rename to libs/nikiroo-utils-1.5.1-sources.jar index 13b8f98..786794b 100644 Binary files a/libs/nikiroo-utils-1.5.0-sources.jar and b/libs/nikiroo-utils-1.5.1-sources.jar differ diff --git a/src/be/nikiroo/fanfix/reader/BasicReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java index 74bd5d4..7b9c98c 100644 --- a/src/be/nikiroo/fanfix/reader/BasicReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -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;