Last active
October 3, 2021 19:17
-
-
Save yonderbread/4dedf2650b066c7d2a75cb90f5c3169a to your computer and use it in GitHub Desktop.
A tiny, minimal todo program written in python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os, sys | |
todo_cfg=os.path.expanduser("~/.config/todo") | |
todo_fp=os.path.join(todo_cfg, 'list') | |
if __name__ == '__main__': | |
if len(sys.argv) == 1: | |
if not os.path.exists(todo_cfg): os.mkdir(todo_cfg) | |
if not os.path.exists(todo_fp): | |
with open(todo_fp, 'w') as f: f.close() | |
with open(todo_fp) as f: | |
entries = f.readlines() | |
for i in range(0,len(entries)): | |
if (len(entries[i].split(' ')) >= 1): | |
status,desc = ( | |
entries[i].split(' ')[0], | |
entries[i].split(' ')[1:]) | |
_status = f'{status} ' | |
if os.environ.get('TODO_USE_TERMCOLOR') == '1': | |
if status == '?': | |
_status = '\033[33m' + status +'\033[0m \033[4m' | |
if status == '!': | |
_status = '\033[32m' + status + '\033[0m \033[9m' | |
if os.environ.get('TODO_USE_ICONS') == '1': | |
_status = _status.replace('?','') | |
_status = _status.replace('!','') | |
print(f'{_status}{" ".join(x for x in desc)}\033[0m'.strip('\n')) | |
else: | |
print(f'Error in {todo_fp}: Incorrect formatting on line {str(i+1)}\n') | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment