Last active
March 31, 2017 05:33
-
-
Save thewhitetulip/9bb96d662c0dedf3901e91b456beadab to your computer and use it in GitHub Desktop.
tasks.py
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
import sys | |
arguments = sys.argv | |
arguments = arguments[1:] | |
command = arguments[0] | |
help=""" | |
usage: | |
tasks.py add "learn python" "write code" | |
tasks.py delete [title] | |
tasks.py list | |
""" | |
if command == "add": | |
output_file = open("ztasks.txt", "a") | |
title, content = arguments[1], arguments[2] | |
output_file.write("%s--%s\n"%(title , content)) | |
output_file.close() | |
print("task added") | |
elif command == "list": | |
input_file = open("ztasks.txt", "r") | |
lines = input_file.readlines() | |
lines = [line.strip() for line in lines] | |
print("Title\t\t\t\tContent\n") | |
print("-"*50) | |
for line in lines: | |
line = line.split("--") | |
title, content = line[0], line[1] | |
print("%s\t%s\n"%( title, content)) | |
input_file.close() | |
else: | |
print(help) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment