This repository has been archived on 2022-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
ztm/ztm.py

81 lines
1.7 KiB
Python
Raw Normal View History

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
from tag import Tag
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()
self.tag = Tag()
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':
self.tag.manage_tag()
2018-02-16 09:16:29 +00:00
self.menu()
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
else:
2019-01-07 06:58:44 +00:00
self.screen.add_fail('This is not implemented...')
self.menu()
2018-02-14 15:16:03 +00:00
if __name__ == '__main__':
a = Main()
a.run()