X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FCliReader.java;h=8a45885646cde715febce086981272157c04997c;hp=de55bf9b06a8a033662037c14cb412f1615844e1;hb=bc2ea776b67cabcbdcbbc6d8a4e2df1aafa9101a;hpb=6322ab64949f9f4ae2b04b9504d58a301039d670 diff --git a/src/be/nikiroo/fanfix/reader/CliReader.java b/src/be/nikiroo/fanfix/reader/CliReader.java index de55bf9..8a45885 100644 --- a/src/be/nikiroo/fanfix/reader/CliReader.java +++ b/src/be/nikiroo/fanfix/reader/CliReader.java @@ -19,24 +19,23 @@ import be.nikiroo.fanfix.data.Story; */ class CliReader extends BasicReader { public void read() throws IOException { - if (getStory() == null) { + MetaData meta = getMeta(); + + if (meta == null) { throw new IOException("No story to read"); } String title = ""; String author = ""; - MetaData meta = getStory().getMeta(); - if (meta != null) { - if (meta.getTitle() != null) { - title = meta.getTitle(); - } + if (meta.getTitle() != null) { + title = meta.getTitle(); + } - if (meta.getAuthor() != null) { - author = "©" + meta.getAuthor(); - if (meta.getDate() != null && !meta.getDate().isEmpty()) { - author = author + " (" + meta.getDate() + ")"; - } + if (meta.getAuthor() != null) { + author = "©" + meta.getAuthor(); + if (meta.getDate() != null && !meta.getDate().isEmpty()) { + author = author + " (" + meta.getDate() + ")"; } } @@ -44,7 +43,8 @@ class CliReader extends BasicReader { System.out.println(author); System.out.println(""); - for (Chapter chap : getStory()) { + // TODO: progress? + for (Chapter chap : getStory(null)) { if (chap.getName() != null && !chap.getName().isEmpty()) { System.out.println(Instance.getTrans().getString( StringId.CHAPTER_NAMED, chap.getNumber(), @@ -57,14 +57,17 @@ class CliReader extends BasicReader { } public void read(int chapter) throws IOException { - if (getStory() == null) { + MetaData meta = getMeta(); + + if (meta == null) { throw new IOException("No story to read"); } - if (chapter > getStory().getChapters().size()) { + // TODO: progress? + if (chapter > getStory(null).getChapters().size()) { System.err.println("Chapter " + chapter + ": no such chapter"); } else { - Chapter chap = getStory().getChapters().get(chapter - 1); + Chapter chap = getStory(null).getChapters().get(chapter - 1); System.out.println("Chapter " + chap.getNumber() + ": " + chap.getName());