aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wikijscmd/app.py5
-rw-r--r--wikijscmd/commands.py8
2 files changed, 11 insertions, 2 deletions
diff --git a/wikijscmd/app.py b/wikijscmd/app.py
index c16a446..7b2fe0f 100644
--- a/wikijscmd/app.py
+++ b/wikijscmd/app.py
@@ -4,7 +4,7 @@ import sys
import argparse
from wikijscmd.config import config
-from wikijscmd.commands import create, edit, single, tree, today, move, fill_in_pages
+from wikijscmd.commands import create, edit, single, tree, today, move, fill_in_pages, latest_journal_entry
from wikijscmd.tui import tui
def main():
@@ -41,6 +41,9 @@ def main():
parser_journal = subparsers.add_parser("journal", help="create journal pages")
parser_journal.set_defaults(command=fill_in_pages)
+ parser_last_journal = subparsers.add_parser("last_journal", help="check journal pages")
+ parser_last_journal.set_defaults(command=latest_journal_entry)
+
parser_tui = subparsers.add_parser("tui", help="lauch a ncurses interface")
parser_tui.set_defaults(command=tui)
diff --git a/wikijscmd/commands.py b/wikijscmd/commands.py
index 86cfe7b..84f8916 100644
--- a/wikijscmd/commands.py
+++ b/wikijscmd/commands.py
@@ -85,7 +85,7 @@ def edit(path, save=False):
sys.exit(1)
print(result["message"])
-def fill_in_pages():
+def latest_journal_entry(print_result=True):
last_date = None
for page in get_tree("journal"):
try:
@@ -94,6 +94,12 @@ def fill_in_pages():
last_date = date
except ValueError:
continue
+ if print_result:
+ print(last_date)
+ return last_date
+
+def fill_in_pages():
+ last_date = latest_journal_entry(print_result=False)
today = datetime.now().date()
if last_date is None:
last_date = today