From a5f2f404b33fb1fc841b796a9848d7e24a0923e6 Mon Sep 17 00:00:00 2001 From: Arnas Udovicius Date: Fri, 9 Mar 2018 22:17:45 +0200 Subject: [PATCH] active tasks --- model.py | 7 +++++-- ztm.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/model.py b/model.py index cdba3e5..28519fc 100644 --- a/model.py +++ b/model.py @@ -1,6 +1,7 @@ import sqlite3 from abcex import Abcex +from params import Params class Model: @@ -9,6 +10,8 @@ class Model: self.conn.row_factory = sqlite3.Row self.abcex = Abcex() + self.params = Params() + def get_tasks_by_tag(self, tag_name): query = ''' SELECT t.* FROM task t @@ -21,11 +24,11 @@ class Model: def get_all_tasks(self, done=False, active=False): done_query = '' - if done: + if done or self.params.get('done'): done_query = 'AND t.done = 1' active_query = '' - if active: + if active or self.params.get('active'): active_query = 'AND t.active = 1' query = ''' diff --git a/ztm.py b/ztm.py index 0441c6d..60b1901 100644 --- a/ztm.py +++ b/ztm.py @@ -1,3 +1,4 @@ +import argparse import sys from pyfzf.pyfzf import FzfPrompt @@ -7,6 +8,7 @@ from task import Task from tag import Tag from config import Config from bcolors import bcolors +from params import Params class Main: @@ -15,9 +17,19 @@ class Main: self.task = Task() self.tag = Tag() self.config = Config() + self.params = Params() + self.fzf = FzfPrompt() + self.parser = argparse.ArgumentParser('ztm') + self.parser.add_argument('-c', '--current', dest='active', action='store_true') + self.parser.set_defaults(active=False) + def run(self): + n = self.parser.parse_args() + if n.active: + self.params.update('active', True) + print(bcolors.HEADER + ''' GEEEEEEEL .. : ,##############Wf.,;;L#K;;. ,W, .Et