# # Copyright 2005 Perforce Software. All rights reserved. # require "P4Form.rb" if ARGV[0] == nil fullform = P4Form.new(`p4 jobspec -o`.split("\n")) else formfile=File.new(ARGV[0]) fullform = P4Form.new(formfile) formfile.close end valueform = P4Form.new(fullform.fields["Values"].split("\n").collect!{|x| x.gsub(/^[ ]*([^ ]*) /,'\1: ')}) valueform.fieldnames.each do |field| printf "\"%s\" => ", field case valueform.fields[field] when /^[ ]*ListOf[(]/ listtype = valueform.fields[field].gsub(/^[ ]*ListOf[(](.*)[)][ ]*$/, '\1') case listtype when /^[ ]*Changelist[(][)]/ printf "\"islistof(\\\"$VALUE\\\", \\\"ischangelist\\\")\"" when /^[ ]*UserID[(][)]/ printf "\"islistof(\\\"$VALUE\\\", \\\"isuserid\\\")\"" when /^[ ]*JobID[(][)]/ printf "\"islistof(\\\"$VALUE\\\", \\\"isjobid\\\")\"" when /^[ ]*DepotPath[(][)]/ printf "\"islistof(\\\"$VALUE\\\", \\\"isdepotpath\\\")\"" when /^[ ]*FilePath[(][)]/ printf "\"islistof(\\\"$VALUE\\\", \\\"isfilepath\\\")\"" else # Ignore unhandled validation specification printf "\"true\"" end when /^[ ]*Changelist[(][)]/ printf "\"ischangelist(\\\"$VALUE\\\")\"" when /^[ ]*UserID[(][)]/ printf "\"isuserid(\\\"$VALUE\\\")\"" when /^[ ]*JobID[(][)]/ printf "\"isjobid(\\\"$VALUE\\\")\"" when /^[ ]*DepotPath[(][)]/ printf "\"isdepotpath(\\\"$VALUE\\\")\"" when /^[ ]*FilePath[(][)]/ printf "\"isfilepath(\\\"$VALUE\\\")\"" else # Ignore unhandled validation specification printf "\"true\"" end printf ",\n" end