#NEWLINE# @ click . command ( help = 'Add the current document to the bookmarks, with the given NAME.' ) #NEWLINE# @ click . argument ( 'name' , nargs = 1 ) #NEWLINE# def bookmarks_add( name ) : #NEWLINE# #INDENT# doc = get_document ( ) #NEWLINE# if ( doc is None ) : #NEWLINE# #INDENT# click . echo ( 'No current document. Use `coreapi get` to fetch a document first.' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# bookmarks = get_bookmarks ( ) #NEWLINE# bookmarks [ name ] = { #NEWLINE# #INDENT# 'url' : doc . url , #NEWLINE# 'title' : doc . title , #NEWLINE# #UNINDENT# } #NEWLINE# set_bookmarks ( bookmarks ) #NEWLINE# click . echo ( click . style ( 'Added bookmark' , bold = True ) ) #NEWLINE# click . echo ( name )