diff --git a/projects/todo-cli-app/README.md b/projects/todo-cli-app/README.md deleted file mode 100644 index 3c8bb810..00000000 --- a/projects/todo-cli-app/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Simple CLI Todo App -Simple Todo app with command line interface. Supports adding, deleting, and viewing task entries. - -## Dependencies -Requires Python 3 and Click - -Install Click: `pip install click` - -## How to use -### Running -`python todo.py [command]` - -### Commands -|Command | Description| -|-------|-------| -|`add`| Adds a task. Prompts user for task text. | -|`done`| Deletes a task. Prompts user for task id. | -|`tasks`| Displays all inputted tasks. \ No newline at end of file diff --git a/projects/todo-cli-app/todo.py b/projects/todo-cli-app/todo.py deleted file mode 100644 index 3f09c4b5..00000000 --- a/projects/todo-cli-app/todo.py +++ /dev/null @@ -1,68 +0,0 @@ -import click - -@click.group() -@click.pass_context -def todo(ctx): - '''Simple CLI Todo App''' - ctx.ensure_object(dict) - #Open todo.txt – first line contains latest ID, rest contain tasks and IDs - with open('./todo.txt') as f: - content = f.readlines() - #Transfer data from todo.txt to the context - ctx.obj['LATEST'] = int(content[:1][0]) - ctx.obj['TASKS'] = {en.split('```')[0]:en.split('```')[1][:-1] for en in content[1:]} - -@todo.command() -@click.pass_context -def tasks(ctx): - '''Display tasks''' - if ctx.obj['TASKS']: - click.echo('YOUR TASKS\n**********') - #Iterate through all the tasks stored in the context - for i, task in ctx.obj['TASKS'].items(): - click.echo('• ' + task + ' (ID: ' + i + ')') - click.echo('') - else: - click.echo('No tasks yet! Use ADD to add one.\n') - -@todo.command() -@click.pass_context -@click.option('-add', '--add_task', prompt='Enter task to add') -def add(ctx, add_task): - '''Add a task''' - if add_task: - #Add task to list in context - ctx.obj['TASKS'][ctx.obj['LATEST']] = add_task - click.echo('Added task "' + add_task + '" with ID ' + str(ctx.obj['LATEST'])) - #Open todo.txt and write current index and tasks with IDs (separated by " ``` ") - curr_ind = [str(ctx.obj['LATEST'] + 1)] - tasks = [str(i) + '```' + t for (i, t) in ctx.obj['TASKS'].items()] - with open('./todo.txt', 'w') as f: - f.writelines(['%s\n' % en for en in curr_ind + tasks]) - -@todo.command() -@click.pass_context -@click.option('-fin', '--fin_task_id', prompt='Enter ID of task to finish', type=int) -def done(ctx, fin_task_id): - '''Delete a task by ID''' - #Find task with associated ID - if str(fin_task_id) in ctx.obj['TASKS'].keys(): - task = ctx.obj['TASKS'][str(fin_task_id)] - #Delete task from task list in context - del ctx.obj['TASKS'][str(fin_task_id)] - click.echo('Finished and removed task "' + task + '" with id ' + str(fin_task_id)) - #Open todo.txt and write current index and tasks with IDs (separated by " ``` ") - if ctx.obj['TASKS']: - curr_ind = [str(ctx.obj['LATEST'] + 1)] - tasks = [str(i) + '```' + t for (i, t) in ctx.obj['TASKS'].items()] - with open('./todo.txt', 'w') as f: - f.writelines(['%s\n' % en for en in curr_ind + tasks]) - else: - #Resets ID tracker to 0 if list is empty - with open('./todo.txt', 'w') as f: - f.writelines([str(0) + '\n']) - else: - click.echo('Error: no task with id ' + str(fin_task_id)) - -if __name__ == '__main__': - todo() \ No newline at end of file diff --git a/projects/todo-cli-app/todo.txt b/projects/todo-cli-app/todo.txt deleted file mode 100644 index c2270834..00000000 --- a/projects/todo-cli-app/todo.txt +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file