X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FCliReader.java;h=2f0b8cee32910ffae7e31374b807a3cd2d65f32c;hb=211f7ddb50f68aa8a999023ef6d63d5756bdace6;hp=b3dd3edc79300b28c2ea779c91c887bbbbd9d704;hpb=3727aae2b0516c5ed5366cde29544565f1d6c6b0;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/CliReader.java b/src/be/nikiroo/fanfix/reader/CliReader.java index b3dd3ed..2f0b8ce 100644 --- a/src/be/nikiroo/fanfix/reader/CliReader.java +++ b/src/be/nikiroo/fanfix/reader/CliReader.java @@ -9,7 +9,6 @@ import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; import be.nikiroo.fanfix.data.Story; -import be.nikiroo.fanfix.supported.BasicSupport.SupportType; /** * Command line {@link Story} reader. @@ -21,24 +20,23 @@ import be.nikiroo.fanfix.supported.BasicSupport.SupportType; class CliReader extends BasicReader { @Override 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() + ")"; } } @@ -46,7 +44,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(), @@ -58,12 +57,18 @@ class CliReader extends BasicReader { } } - @Override - public void read(int chapter) { - if (chapter > getStory().getChapters().size()) { + public void read(int chapter) throws IOException { + MetaData meta = getMeta(); + + if (meta == null) { + throw new IOException("No story to read"); + } + + // 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()); @@ -75,9 +80,9 @@ class CliReader extends BasicReader { } @Override - public void start(SupportType type) { + public void browse(String source) { List stories; - stories = Instance.getLibrary().getList(type); + stories = getLibrary().getListBySource(source); for (MetaData story : stories) { String author = "";