diff --git a/setup.py b/setup.py index e4a81ca..b43d851 100755 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ ' ({}.{} detected).'.format(*version)) sys.exit(-1) -VERSION = '0.5.1' +VERSION = '0.7' def install(mute=True): diff --git a/tdo/main.py b/tdo/main.py index 118e685..456b1ad 100755 --- a/tdo/main.py +++ b/tdo/main.py @@ -100,6 +100,11 @@ def main(argv=sys.argv): displayhelp() elif argv[1] == 'update': todolist.update() + elif argv[1] == 'themes': + todolist.listthemes() + elif argv[1] == 'settheme': + settings = todolist.settheme(argv, settings) + todolist.savesettings(settings) else: # something wrong? Help! displayhelp() diff --git a/tdo/todolist/__init__.py b/tdo/todolist/__init__.py index c2fd792..7dbc9e8 100644 --- a/tdo/todolist/__init__.py +++ b/tdo/todolist/__init__.py @@ -4,3 +4,4 @@ from .maintenance import * from .help import * from .printing import * +from .theme import * diff --git a/tdo/todolist/help.py b/tdo/todolist/help.py index 3ac5678..5f473d7 100644 --- a/tdo/todolist/help.py +++ b/tdo/todolist/help.py @@ -12,4 +12,6 @@ tdo lists List all lists with a statistic of undone/done tasks. tdo help Display this help. tdo reset DANGER ZONE. Delete all your todos and todo lists. -tdo update Updates tdo to the latest release.''' +tdo update Updates tdo to the latest release. +tdo themes Shows all available themes. +tdo settheme id Set the theme to ''' diff --git a/tdo/todolist/printing.py b/tdo/todolist/printing.py index 166e226..b5bb5ca 100644 --- a/tdo/todolist/printing.py +++ b/tdo/todolist/printing.py @@ -43,9 +43,11 @@ def printtask(num_len, task_id, name, table, tick, done=False): donestr = '[x]' if done else '[ ]' if table: - print(' {done} |{id} | {task}'.format(done=donestr, - id=printedId, - task=tasklist[0])) + space = (5 - num_len) if spaces == 0 else spaces + print(' {done} |{space}{id} | {task}'.format(done=donestr, + space=' ' * space, + id=printedId, + task=tasklist[0])) if len(tasklist) > 1: for element in range(len(tasklist) - 1): print(' |{idlen}| {task}'.format(idlen=' ' * (maxLen - 6), diff --git a/tdo/todolist/theme.py b/tdo/todolist/theme.py new file mode 100644 index 0000000..3f88871 --- /dev/null +++ b/tdo/todolist/theme.py @@ -0,0 +1,44 @@ +from .listing import listall +import json + +num_len = 1 +examplelist = {'default': { + '1': ['This is an example', False], '2': ['This one is done', True]}} +tempsettings = {'globalid': 1, 'table': False, 'tick': False} + + +def listthemes(): + print('\033[1m\033[91mTheme 1:\033[0m') + listall(examplelist, num_len, tempsettings) + print('\033[1m\033[91mTheme 2:\033[0m') + tempsettings['tick'] = True + listall(examplelist, num_len, tempsettings) + print('\033[1m\033[91mTheme 3:\033[0m') + tempsettings['tick'] = False + tempsettings['table'] = True + listall(examplelist, num_len, tempsettings) + print('\033[1m\033[91mTheme 4:\033[0m') + tempsettings['tick'] = True + listall(examplelist, num_len, tempsettings) + + +def settheme(argv, settings): + if len(argv) < 3: + print('You have to select a theme.\nYou can get a list of all themes \ +with "themes"') + elif argv[2] == '1': + settings['tick'] = False + settings['table'] = False + elif argv[2] == '2': + settings['tick'] = True + settings['table'] = False + elif argv[2] == '3': + settings['tick'] = False + settings['table'] = True + elif argv[2] == '4': + settings['tick'] = True + settings['table'] = True + else: + print('There is no theme {id}.\nYou can get a list of all themes \ +with "themes"'.format(id=argv[2])) + return settings