#!/usr/bin/ruby require "P4" #******************************************************************************* # Construct your client # p4 = P4.new() #******************************************************************************* # Perforce client environment - getting the default settings # # p4.client - Get P4CLIENT # p4.host - Get P4HOST # p4.password - Get P4PASSWD # p4.port - Get P4PORT # p4.user - Get P4USER # print <" # rather than passing the command name as an argument to the run method. For # example info = p4.run_info() user_spec = p4.run_user( "-o" ).shift user_list = p4.run_users() protections = p4.run_protect( "-o" ).shift #******************************************************************************* # There are also shortcut methods to make form editing easy. Any method # taking the form "fetch_" is equivalent to running "p4 -o" # and likewise any method taking the form "save_" is equivalent to # running "p4 -i". These methods do not return an array - they # return only one element, since that's all that Perforce will return to you. # # Note that all of the "save*" methods require an argument. The argument # can be either a string containing the edited form, or it can be the edited # hash returned from a previous "fetch*" call. # client_spec = p4.fetch_client() client_spec[ "Owner" ] = "tony" # p4.save_client( client_spec ) rescue P4Exception => msg puts( msg ) p4.warnings.each { |w| puts( w ) } p4.errors.each { |e| puts( e ) } p4.output.each { |o| puts( o ) } end