def gen_proto(args):
    '''Generate proto from sql file'''
    print '-'*50
    print 'Generating .proto\n'
    
    if len(args) < 2: 
        print '''Using 'config/server_database.sql' for sql file, 'shared/man_db_msg.proto' for proto file. 
If you don't want it:
    Usage: gen_proto sql_filename proto_filename'''
        
        dir = os.path.dirname(os.path.abspath(__file__)) + '/'
        sql_filename = dir + 'config/server_database.sql'
        proto_filename = 'shared/man_db_msg.proto'
    else:
        sql_filename = args[0]
        proto_filename = args[1]
    db = sql_sparser.get_db_struct(sql_filename)
    p = db2proto_gen.protogen()
    p.from_db(db, proto_filename)
    print '-'*50 + '\n'
def gen_orm(args):
    '''Generate orm from sql file'''
    print '-'*50
    print 'Generating orm\n'
    
    dir = os.path.dirname(os.path.abspath(__file__)) + '/'
    if len(args) < 2:
        print '''Using 'config/server_database.sql' for sql file, 'shared/orm.py' for orm file. 
If you don't want it:
    Usage: gen_orm sql_filename orm_filename'''
        orm_filename = dir + 'shared/orm.py'
        sql_filename = dir + 'config/server_database.sql'
    else: 
        sql_filename = args[0]
        orm_filename = args[1]
        
    orm_file = open(orm_filename, 'w')
    db = sql_sparser.get_db_struct(sql_filename)

    res_str = db2orm_gen.generate_classes(db)
    orm_file.write(res_str)
    orm_file.close()
    print '-'*50 + '\n'