Example #1
0
def list_main():
    opt = [
        inquirer.List(
            'opt',
            message="Choose list option",
            choices=['due', 'what', 'importance', 'category'],
        ),
    ]
    answers = inquirer.prompt(opt)

    if answers['opt'] == 'due':
        list_todo_due()
    elif answers['opt'] == 'what':
        list_todo_what()
    elif answers['opt'] == 'importance':
        list_todo_importance()
    elif answers['opt'] == 'category':
        ctg.show_category()
        c = str(input("What cateogry do you want to list? "))
        cmp_data = "select distinct category from todo"
        cur.execute(cmp_data)
        cmp_records = cur.fetchall()
        cmp_list = []
        for i in range(len(cmp_records)):
            cmp_list.append(cmp_records[i][0])
        while True:
            if not c in cmp_list:
                print("There is not", c, "Please enter the 'what' in table")
                c = str(input())
            else:
                break
        list_todo_category(c)
Example #2
0
def run_program():
    """Run program if usr executes RedList without any option"""
    while True:
        af.auto_fin()
        mode = [
            inquirer.List(
                'mode',
                message="Choose what you ganna do",
                choices=[
                    'Add todo', 'List todo', 'Modify todo', 'Delete todo',
                    'Show category', 'Quit'
                ],
            ),
        ]
        answers = inquirer.prompt(mode)
        if answers['mode'] == 'Add todo':
            at.add_todo()
        elif answers['mode'] == 'List todo':
            li.list_main()
        elif answers['mode'] == 'Modify todo':
            md.modify_todo()
        elif answers['mode'] == 'Delete todo':
            dl.del_todo()
        elif answers['mode'] == 'Show category':
            ctg.show_category()
        elif answers['mode'] == 'Quit':
            break
        af.auto_fin()
Example #3
0
def list_main():
    opt = input("(1: due, 2: what, 3: importance, 4: category)? ")
    while not opt.isdigit():
        opt = input("(1: due, 2: what, 3: importance, 4: category)? ")
    opt = int(opt)
    while opt < 1 or opt > 4:
        opt = int(input("(1: due, 2: what, 3: importance, 4: category)? "))
    if opt == 1:
        list_todo_due()
    elif opt == 2:
        list_todo_what()
    elif opt == 3:
        list_todo_importance()
    elif opt == 4:
        ctg.show_category()
        c = str(input("What category do you want to list? "))
        list_todo_category(c)
Example #4
0
def list_main():
    opt = [
        inquirer.List(
            'opt',
            message="Choose list option",
            choices=['due', 'what', 'importance', 'category'],
        ),
    ]
    answers = inquirer.prompt(opt)

    if answers['opt'] == 'due':
        list_todo_due()
    elif answers['opt'] == 'what':
        list_todo_what()
    elif answers['opt'] == 'importance':
        list_todo_importance()
    elif answers['opt'] == 'category':
        ctg.show_category()
        list_todo_category(c)
Example #5
0
def list_main():
    opt = [
        inquirer.List(
            'opt',
            message="Choose list option",
            choices=['due', 'what', 'importance', 'category'],
        ),
    ]
    answers = inquirer.prompt(opt)

    if answers['opt'] == 'due':
        list_todo_due()
    elif answers['opt'] == 'what':
        list_todo_what()
    elif answers['opt'] == 'importance':
        list_todo_importance()
    elif answers['opt'] == 'category':
        ctg.show_category()
        c = str(input("What cateogry do you want to list? "))
        chk_is_there(c)

        list_todo_category(c)
Example #6
0
def run_program():
	while True:
		print("Choose what to do")
		af.auto_fin()
		mode = [
			inquirer.List('mode',
				message="Choose what to do",
				choices=['Add todo', 'List todo', 'Modify todo', 'Delete todo', 'Show category', 'Quit'],
			),
		]
		answers = inquirer.prompt(mode)
		if answers['mode'] == 'Add todo':
			at.add_todo()
		elif answers['mode'] == 'List todo':
			li.list_main()
		elif answers['mode'] == 'Modify todo':
			md.modify_todo()
		elif answers['mode'] == 'Delete todo':
			dl.del_todo()
		elif answers['mode'] == 'Show category':
			ctg.show_category()
		elif answers['mode'] == 'Quit':
			break
		af.auto_fin()
Example #7
0
def cmd_line():
	"""Usr inputs option among -a(add todo), -l(list todo), -m(modify todo), -d(delete todo), -c(show category)"""

	usage = "Usage: %prog [options]"
	parser = OptionParser(usage=usage, version="%prog 0.0.5")
	parser.add_option("-a", dest="add", action='store', type=str, default=False, help="add a new todo",
						metavar="[what] [due(yyyy-mm-dd hh:mm:ss)] [importance(0~5)] [category]")
	parser.add_option("-l", dest="list", action='store', type=str, default=False, help="list todos by option",
						metavar="what || due || importance || category [category]")
	parser.add_option("-m", dest="modify", action='store', type=str, default=False, help="modify the todo",
						metavar="[org_what] [what] [due(yyyy-mm-dd hh:mm:ss)] [importance(0~5)] [category] [finished(y/n)]")
	parser.add_option("-d", dest="delete", action='store', type=str, default=False, help="delete the todo",
						metavar="[what]")
	parser.add_option("-c", dest="category", action='store_true', default=False, help="show categories")

	options, args = parser.parse_args()

	# no option
	if len(args) == 0 and not (options.add or options.list or options.modify or options.delete or options.category):
		lg.print_logo()
		run_program()

	if options.add:
		sql = "insert into todo (what, due, importance, category, finished) values (?, ?, ?, ?, ?)"
		what, due, importance, category = options.add, args[0]+" "+args[1], args[2], args[3]
		if not dc.isdue(due):
			print('Invaild input! Please check your input(yyyy-mm-dd hh:mm:ss)')
			exit()
		data = [what, due, importance, category, "n"]
		cur.execute(sql, data)
		print("ADDED")
		conn.commit()

	if options.list:
		op = options.list
		if op == 'what':
			li.list_todo_what()
		elif op == 'due':
			li.list_todo_due()
		elif op == 'importance':
			li.list_todo_importance()
		elif op == 'category':
			# check whether category is exsited in todo table
			c = args[0]
			cmp_data = "select distinct category from todo"
			cur.execute(cmp_data)
			cmp_records = cur.fetchall()
			cmp_list = []
			for i in range(len(cmp_records)):
				cmp_list.append(cmp_records[i][0])
			if not c in cmp_list:
				print("There is not", c)
			li.list_todo_category(c)

	if options.modify:
		modify_data = options.modify
		# check whether there is the modify val in table
		chk_is_there(modify_data)

		what, due, importance, category, finished = args[0], args[1]+" "+args[2], args[3], args[4], args[5]
		sql = "update todo set what = ?, due = ?, importance = ?, category = ?, finished = ? where what = ?"
		cur.execute(sql, [what, due, int(importance), category, finished, modify_data])
		print("MODIFIED")
		conn.commit()

	if options.delete:
		delete_data = options.delete
		# check whether there is the delete_data val in table
		chk_is_there(delete_data)

		del_record = "delete from todo where what = ?"
		cur.execute(del_record, [delete_data])
		print("DELETED")
		conn.commit()

	if options.category:
		ctg.show_category()