def new(args = None): """ Create a new note. """ parser = argparse.ArgumentParser(description='Create a new note') parser.add_argument('--title', help='title for the new note') parser.add_argument('--no-edit', action='store_true', help='optional filename for the new note') parser.add_argument('--no-view', action='store_true', help='optional filename for the new note') args = parser.parse_args(args) title = args.title if not title: title = notes.time_as_filename() filename = notes.title_to_filename(title, ".md") with open(filename, "w") as new_file: new_file.write(notes.get_header(title)) print "Created new note with name: {0}".format(filename) if not args.no_edit: notes.edit(filename) if not args.no_view: notes.view_file(filename)
def view(args = None): """ View a note in the browser. """ parser = argparse.ArgumentParser(description='Create a new note') parser.add_argument('filename', help='filename to view') args = parser.parse_args(args) notes.view_file(args.filename)