git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Woopsie
[nikiroo-utils.git]
/
src
/
be
/
nikiroo
/
fanfix
/
reader
/
CliReader.java
diff --git
a/src/be/nikiroo/fanfix/reader/CliReader.java
b/src/be/nikiroo/fanfix/reader/CliReader.java
index f9e4b700f804780861780a695dfbc98a56f36a60..2f0b8cee32910ffae7e31374b807a3cd2d65f32c 100644
(file)
--- a/
src/be/nikiroo/fanfix/reader/CliReader.java
+++ b/
src/be/nikiroo/fanfix/reader/CliReader.java
@@
-20,24
+20,23
@@
import be.nikiroo.fanfix.data.Story;
class CliReader extends BasicReader {
@Override
public void read() throws IOException {
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 = "";
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() + ")";
}
}
}
}
@@
-45,7
+44,8
@@
class CliReader extends BasicReader {
System.out.println(author);
System.out.println("");
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(),
if (chap.getName() != null && !chap.getName().isEmpty()) {
System.out.println(Instance.getTrans().getString(
StringId.CHAPTER_NAMED, chap.getNumber(),
@@
-57,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 {
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());
System.out.println("Chapter " + chap.getNumber() + ": "
+ chap.getName());
@@
-74,9
+80,9
@@
class CliReader extends BasicReader {
}
@Override
}
@Override
- public void
start(String typ
e) {
+ public void
browse(String sourc
e) {
List<MetaData> stories;
List<MetaData> stories;
- stories =
Instance.getLibrary().getList(typ
e);
+ stories =
getLibrary().getListBySource(sourc
e);
for (MetaData story : stories) {
String author = "";
for (MetaData story : stories) {
String author = "";