#NEWLINE# def do_command( params ) : #NEWLINE# #INDENT# if ( params . command == 'q' ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command == 'l' ) : #NEWLINE# #INDENT# if ( len ( params . record_cache ) == 0 ) : #NEWLINE# #INDENT# print ( 'No records' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# results = api . search_records ( params , '' ) #NEWLINE# display . formatted_records ( results ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command [ : 2 ] == 'g ' ) : #NEWLINE# #INDENT# r = api . get_record ( params , params . command [ 2 : ] ) #NEWLINE# if r : #NEWLINE# #INDENT# r . display ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command [ : 2 ] == 'r ' ) : #NEWLINE# #INDENT# api . rotate_password ( params , params . command [ 2 : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command == 'c' ) : #NEWLINE# #INDENT# print ( ( chr ( 27 ) + '[2J' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command [ : 2 ] == 's ' ) : #NEWLINE# #INDENT# results = api . search_records ( params , params . command [ 2 : ] ) #NEWLINE# display . formatted_records ( results ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command [ : 2 ] == 'b ' ) : #NEWLINE# #INDENT# results = api . search_records ( params , params . command [ 2 : ] ) #NEWLINE# for r in results : #NEWLINE# #INDENT# api . rotate_password ( params , r . record_uid ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command == 'd' ) : #NEWLINE# #INDENT# api . sync_down ( params ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command == 'a' ) : #NEWLINE# #INDENT# api . add_record ( params ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command == 'h' ) : #NEWLINE# #INDENT# display . formatted_history ( stack ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command == 'debug' ) : #NEWLINE# #INDENT# if params . debug : #NEWLINE# #INDENT# params . debug = False #NEWLINE# print ( 'Debug OFF' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# params . debug = True #NEWLINE# print ( 'Debug ON' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( params . command == '' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( '\n\nCommands:\n' ) #NEWLINE# print ( '  d         ... download & decrypt data' ) #NEWLINE# print ( '  l         ... list folders and titles' ) #NEWLINE# print ( '  s <regex> ... search with regular expression' ) #NEWLINE# print ( '  g <uid>   ... get record details for uid' ) #NEWLINE# print ( '  r <uid>   ... rotate password for uid' ) #NEWLINE# print ( '  b <regex> ... rotate password for matches of regular expression' ) #NEWLINE# print ( '  a         ... add a new record interactively' ) #NEWLINE# print ( '  c         ... clear the screen' ) #NEWLINE# print ( '  h         ... show command history' ) #NEWLINE# print ( '  q         ... quit' ) #NEWLINE# print ( '' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if params . command : #NEWLINE# #INDENT# if ( params . command != 'h' ) : #NEWLINE# #INDENT# stack . append ( params . command ) #NEWLINE# stack . reverse ( ) #NEWLINE# #UNINDENT# #UNINDENT# return True