#!/usr/bin/env python # Sidenote Taker made by Alex Brown, version 0.0.1 __program__ = 'Sidenote Taker' __version__ = '0.0.1' __usage__ = 'sidenote [OPTIONS]' __author__ = 'Alex Brown ' __doc__ = 'A command-line tool for taking notes in various forms (pro/con, general, etc.) read --help for more information.)' import sys, os from optparse import OptionParser import glob import re import readline global settings; settings = [] global prompt; prompt = ':) ' global bullet; bullet = '*' global init; init = True def new_note(listarg): if chkhelp(listarg,2,'note [|help] []\nMakes a new note sheet'): return def change(listarg): if chkhelp(listarg,2,'change [prompt|bullet] []\nChange settings in this program'): return if listarg[1] == 'prompt': global prompt prompt = listarg[2] elif listarg[1] == 'bullet': global bullet bullet = listarg[2] print "Bullet symbol is now ", bullet def exit(arg): """Exits the note program""" if arg == 0: sys.exit('Good Bye ;)') elif arg == 1: sys.exit('\nGood Bye ;)') else: sys.exit(1) def chkhelp(listarg, numofargs, arg): if len(listarg) == 1: print arg return True elif listarg[1] == 'help': print arg return True elif len(listarg) < (numofargs + 1): print arg return True else: return False def chkinput(arg1): """Checks the input against an if statement""" arg = arg1.split() if arg[0] == 'exit' or arg[0] == 'quit' or arg[0] == 'stop': exit(0) elif arg[0] == 'new': new_note(arg) elif arg[0] == 'change': change(arg) elif arg[0] == 'init' or arg[0] == 'initialize': init() else: print "Unknown command:", arg1 def init(): """Initializes system folders and preference files""" try: os.system("mkdir $HOME/.sidenote") os.system("mkdir $HOME/.sidenote/notefiles") except: print "Failed to initialize system folders and preference files.\nSidenote Taker may not work properly." return def main(*args): """Main Function""" global prompt while True: try: userinput = raw_input(prompt) except EOFError: exit(1) except KeyboardInterrupt: exit(1) chkinput(userinput) if __name__ == '__main__': main()