Main Page

CMDtodo():

A simple todo list manager for the command-line.

I enjoy using terminal interfaces for as many things as possible. I keep a todo list in a .txt file and I wanted to be able to modify it within the console, (Merely appending documents wasn't quite as convenient as I wanted) and so I made this program. It basically just shuffles todo items between a 'todo' file and a 'done' file and allows you to clear both at once.

^ This is the main screen. Like many terminal based apps selections are made by hitting an indicated key and then enter, or entering text for the list content.

|

^ As an example, we'll add a new item by hitting 'n', then we'll enter our test.

|

^ Once we hit enter the new entry will appear under todo and will be assigned a number starting with 0.

|

^ To mark the entry as finished we can hit 'f' and the entries assigned number.

|

^ The entry is moved to finished and the number is removed so that it can be assigned to a new todo entry. 'c' clears the entire list and 'q' closes the program.

|

sourcecode()


# name: ensign(A)
# date: 2018-01-18
# description: Simple to-do list for use in the Windows command-line.
# version 1.0

import sys
import time

todolist = []

def loadlist():
    todolist.clear()
    with open('todo.txt', 'r') as tf:
        num = 0
        for line in tf:
            todolist.insert(num, line)
            num = (num + 1)
        num = 0
    showlist()

def showlist():
    num = 0
    print('\n')
    print("[Finished]")

    ff=open('finished.txt')
    print(ff.read())
    ff.close
    
    print('\n')
    print("[To Do]")
    while (len(todolist) > (num)):
            print(num, todolist[num], end='')
            num = (num + 1)
    commands()


def choicecheck():
    if choice == 'N' or choice == 'n':
        newtask()
    elif choice == 'F' or choice == 'f':
        finished()
    elif choice == 'C' or choice == 'c':
        clearlist()
    elif choice == 'Q' or choice == 'q':
        done()
    
    else:
        commands()

#commands
    
def newtask():
    new = input('Enter new task: ')
    tf = open("todo.txt","a")
    tf.write(new+'\n')
    tf.close()
    loadlist()
    
def finished():
    numst = input("Enter task number: ")
    try:
        num = int(numst)
        done = todolist[num]
        ff = open("finished.txt","a")
        ff.write(done)
        ff.close()
        todolist.pop(num)
        tf=open('todo.txt','w')
        for tasks in todolist:
            tf.write(tasks)
        tf.close()
        loadlist()
    except:
        print('Enter a valid integer.')
        finished()

    
def clearlist():
    open('todo.txt', 'w').close()
    open('finished.txt', 'w').close()
    print("List cleared!")
    loadlist()
    
#messages
    
def welcome():
    print('Welcome to CMDto-do!')
    print('A simple to-do list program for the Windows Command Prompt.')
    print('ensign(A), 2018-01-18')
    
def done():
    print("Goodbye!")
    time.sleep(1)
    #exits program

def commands():
    global choice
    choice = 0
    print('\n')
    print("(N) new task    (F) add to finished    (C) clear list   (Q) quit")
    choice = input("Enter selection: ")
    choicecheck()

#main program
welcome()
loadlist()