2019-01-06 21:13:15 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2018-03-09 20:17:45 +00:00
|
|
|
import argparse
|
2018-02-14 23:34:54 +00:00
|
|
|
|
|
|
|
from pyfzf.pyfzf import FzfPrompt
|
2018-02-13 09:19:09 +00:00
|
|
|
|
2018-02-14 15:16:03 +00:00
|
|
|
from model import Model
|
2018-02-16 05:31:30 +00:00
|
|
|
from task import Task
|
2018-02-16 13:52:58 +00:00
|
|
|
from tag import Tag
|
2018-02-25 20:31:42 +00:00
|
|
|
from config import Config
|
2018-03-09 20:17:45 +00:00
|
|
|
from params import Params
|
2019-01-07 06:58:44 +00:00
|
|
|
from screen import Screen
|
2018-02-13 09:19:09 +00:00
|
|
|
|
2018-02-14 15:16:03 +00:00
|
|
|
|
|
|
|
class Main:
|
|
|
|
def __init__(self):
|
|
|
|
self.model = Model()
|
2018-02-16 05:31:30 +00:00
|
|
|
self.task = Task()
|
2018-02-16 13:52:58 +00:00
|
|
|
self.tag = Tag()
|
2018-02-25 20:31:42 +00:00
|
|
|
self.config = Config()
|
2018-03-09 20:17:45 +00:00
|
|
|
self.params = Params()
|
2019-01-07 06:58:44 +00:00
|
|
|
self.screen = Screen()
|
2018-03-09 20:17:45 +00:00
|
|
|
|
2018-02-14 23:34:54 +00:00
|
|
|
self.fzf = FzfPrompt()
|
2018-02-14 15:16:03 +00:00
|
|
|
|
2018-03-09 20:17:45 +00:00
|
|
|
self.parser = argparse.ArgumentParser('ztm')
|
|
|
|
self.parser.add_argument('-c', '--current', dest='active', action='store_true')
|
|
|
|
self.parser.set_defaults(active=False)
|
|
|
|
|
2018-02-14 15:16:03 +00:00
|
|
|
def run(self):
|
2018-03-09 20:17:45 +00:00
|
|
|
n = self.parser.parse_args()
|
|
|
|
if n.active:
|
|
|
|
self.params.update('active', True)
|
2018-02-14 15:16:03 +00:00
|
|
|
self.menu()
|
|
|
|
|
|
|
|
def menu(self):
|
2019-01-07 06:58:44 +00:00
|
|
|
about = '''
|
|
|
|
Short instruction
|
|
|
|
-----------------
|
|
|
|
? - help (this dialog)
|
|
|
|
+ - add
|
|
|
|
/ - search
|
|
|
|
t - tag manager
|
|
|
|
c - configuration
|
|
|
|
q - exit
|
|
|
|
'''
|
|
|
|
self.screen.change_path('~', '?+/tcq', about)
|
|
|
|
menu = self.screen.print()
|
2018-02-14 15:16:03 +00:00
|
|
|
|
2018-02-16 05:31:30 +00:00
|
|
|
if menu == '?':
|
2019-01-07 06:58:44 +00:00
|
|
|
self.screen.activate_about()
|
|
|
|
self.menu()
|
2018-02-14 15:16:03 +00:00
|
|
|
|
2018-02-16 05:31:30 +00:00
|
|
|
elif menu == '+':
|
|
|
|
self.task.add()
|
|
|
|
self.menu()
|
|
|
|
|
2018-02-14 15:16:03 +00:00
|
|
|
elif menu == '/':
|
2018-02-16 05:31:30 +00:00
|
|
|
self.task.search()
|
|
|
|
self.menu()
|
2018-02-14 15:16:03 +00:00
|
|
|
|
2018-02-16 09:16:29 +00:00
|
|
|
elif menu == 't':
|
2018-02-16 13:52:58 +00:00
|
|
|
self.tag.manage_tag()
|
2018-02-16 09:16:29 +00:00
|
|
|
self.menu()
|
|
|
|
|
2018-02-25 20:31:42 +00:00
|
|
|
elif menu == 'c':
|
|
|
|
self.config.manage()
|
|
|
|
self.menu()
|
|
|
|
|
2018-02-16 05:31:30 +00:00
|
|
|
elif menu == 'q':
|
2019-01-07 06:58:44 +00:00
|
|
|
self.screen.bye()
|
2018-02-14 15:16:03 +00:00
|
|
|
|
2018-02-15 07:16:20 +00:00
|
|
|
else:
|
2019-01-07 06:58:44 +00:00
|
|
|
self.screen.add_fail('This is not implemented...')
|
2018-02-15 07:16:20 +00:00
|
|
|
self.menu()
|
|
|
|
|
2018-02-14 15:16:03 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
a = Main()
|
|
|
|
a.run()
|