#!/usr/bin/env python cmd = "" arg = "" #COMMAND LINE ARGUMENTS HANDLING import sys args = sys.argv num_args = len(args) #Set cmd if num_args>1: cmd = args[1] #Set arg if num_args>2: arg = " ".join(args[2:]) #Help if cmd=="--help" or cmd=="-h" or cmd=="help": print """USAGE: eel [OPTION] [ARGS] eel --help DESCRIPTION: Lists lines submitted by users in chronological order. USAGE: eel new|news Lists all eels in chronological order. eel add Prompts you for the LINE to add to your eels. eel add LINE Adds LINE to your eels. eel user Prompts you for a USERNAME, then lists all their eels. eel user USERNAME Lists all eels added by USERNAME eel users Lists all users with eels. eel --help Prints this help message. """ sys.exit() elif cmd == "": import random slogans = ["Eloquent Elegant Lines", "Emote Extraordinary Love", "Expect Empty Lines", "Every Emotion Lingers", "Extra Entropic Lines", "Ever-Endemic Lexicon", "Esperanto Effects Life", "Evolutionary Egalitarian Lineage", "Excellent Every Line", "Elegant Each Line", "The shortened version of FEELS", "Electronic Envelope Letters", "Enticing Entropic Lines", "Epic Esoteric Lore", "Entheogen Engulfed Lollipops", "Ent's Eternal Light", "Evaporate Extra Liquids", "Enigmatic Empathetic Lore"] slogan = slogans[random.randint(0,len(slogans)-1)] print """ ______________________ | ____ ____ _ | | |___ |___ | | Welcome to EEL! | |___ |___ |___ | %s | Engine 1.0 | The short and sweet line sharing program. |____________________| COMMANDS: Lists all eels in chronological order. add Prompts you for the LINE to add to your eels. add LINE Adds LINE to your eels. user Prompts you for a USERNAME, then lists all their eels. user USERNAME Lists all eels added by USERNAME users Lists all users with eels. """%slogan cmd = raw_input("Command: ") cmd_arr = cmd.split(" ") if len(cmd_arr)>1: cmd = cmd_arr[0] arg = " ".join(cmd_arr[1:]).strip() import popen2 import pydoc if cmd == "add": line = "" if arg=="": line = raw_input("\nType the line you want to add:\n") else: line = arg username_file = popen2.popen2("whoami")[0] username = username_file.readlines()[0].strip() line = "~"+username+": "+line username_file.close() popen2.popen2("echo %s >> eels" % str(line)) print "\neel added..." elif cmd == "user": username = "" if arg=="": username = raw_input("\nWhat username?\n") else: username = arg users_file = popen2.popen2("cat eels | grep -i ^~%s:"%username) users = "\n".join(users_file[0].readlines()) print("") if len(users)>0: pydoc.pager(users) else: print "That user has not posted, or does not exist." users_file[0].close() elif cmd == "users": usernames = [] users_file = popen2.popen2("cat eels")# | grep -i ^~.*:")#***need to figure out how to regex this correctly users = users_file[0].readlines() for u in users: usernames.append(u[1:u.index(':')].strip()) users_file[0].close() usernames = list(set(usernames)) print "" print " ".join(usernames) elif cmd == "psst": line = "" if len(arg)==0: line = raw_input("\nType the line you want to add:\n") else: line = arg print "\neel added anonymously..." line = "~: "+line popen2.popen2("echo %s >> eels" % str(line)) elif cmd=="anon": print "\nLists only lines without usernames.\n" users_file = popen2.popen2("cat eels | grep -i ^~:") users = "\n".join(users_file[0].readlines()) if len(users)>0: pydoc.pager(users) else: print "No anonymously posted lines, yet." users_file[0].close() elif cmd == "new" or cmd == "news" or cmd == "": whole_file = popen2.popen2("cat eels | less") all_lines = "\n".join(whole_file[0].readlines()) pydoc.pager(all_lines) whole_file[0].close() else: print "\nCommand not found." #One file. #Uses 'echo "blah blah blah>>eel"' """ [ 0 ] add an eel [ 1 ] view your eels [ 2 ] view other's eels [ 3 ] global eels """ titles = ["Elegant Every Line", "Elegantly Eloquent Lines", "Elaborately Entropic Lines", "Enlightenment Every Line", "Everyone Enjoys Lines"] """enjoy everyones line sharing entirely exhibitionist line sharing everyones expressive line sharing erradicating extremism line sharing expediated expression line sharing expertly eclectic line sharing excruciatingly essential line sharing excruciatingly enlightening line sharing emboldening enlightening line sharing elegant eloquent line sharing enticing encouraging line sharing eclectically emoted line sharing ecstatically elating line sharing elegantly easy line sharing"""