#!/usr/bin/env ruby # # Triggers: # ForceRmdir form-in client "ForceRmdir.rb %formfile%" # Options: noallwrite noclobber nocompress unlocked nomodtime rmdir if ARGV.length < 1 puts '%formfile% not given.' exit 1 end opts = [0, 0, 0, 0, 0, 0] for i in 1..ARGV.length-1 do option = ARGV[i] if /.*allwrite/ =~ option opts[0] = option end if /.*clobber/ =~ option opts[1] = option end if /.*compress/ =~ option opts[2] = option end if /.*locked/ =~ option opts[3] = option end if /.*modtime/ =~ option opts[4] = option end if /.*rmdir/ =~ option opts[5] = option end end formfile = ARGV[0] form_string = "" form = File.open(formfile, 'r') form.each do |line| if /^Client:.*p4sandbox-.*$/ =~ line form.close exit 0 elsif /^Options:.*?/ =~ line client_choices = line.gsub(/Options:\s+(.*)/, '\1') client_choices = client_choices.strip.split(/\s+/) options_line = line.gsub(/(Options:\s+).*/, '\1').chomp for i in 0..5 do unless opts[i] == 0 options_line << "#{opts[i]} " else options_line << "#{client_choices[i]} " end end options_line = options_line.strip << "\n" form_string << (options_line) else form_string << (line) end end form.close form = File.open(formfile, 'w') form.write(form_string) form.close exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 10137 | jim_brower | Added BSD license to several projects. | ||
#2 | 9836 | jim_brower |
Made significant changes to ForceClientOptions. It now relies less on magic numbers, and should be able to handle the inclusion of future options without exploding. It's also much longer now, for better or for worse. |
||
#1 | 9829 | jim_brower |
Added trigger to let you force any client options you want. Not exactly proud of the implementation, but it seems to work. |