Module: Commands
- Defined in:
- lib/commands/help.rb,
lib/commands/kill.rb,
lib/commands/start.rb,
lib/commands/download.rb
Class Method Summary collapse
- .download(options = nil) ⇒ Object
- .help(options) ⇒ Object
- .kill(options = nil) ⇒ Object
- .print_download_help ⇒ Object
- .print_kill_help ⇒ Object
- .print_start_help ⇒ Object
- .spawn_p4d ⇒ Object
- .start(options) ⇒ Object
Class Method Details
.download(options = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/commands/download.rb', line 8 def Commands.download(=nil) version = 'r14.2' binary = 'p4d' if and !.params.empty? op = OptionParser.new do |op| op.on('-v VERSION', '--version VERSION', 'ftp.perforce.com version') do |v| version = v end end op.parse!(.params) if !.params.empty? binary = .params.first end end case binary when 'p4d' download_p4d_via_ftp(version) when 'p4api' download_p4api_via_ftp(version) else raise "Don't know how to download #{binary}, check 'p4util help download'" end end |
.help(options) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/commands/help.rb', line 4 def Commands.help() if !.params.empty? && Commands.respond_to?(.params.first.to_sym) method_name = "print_#{options.params.first}_help".to_sym Commands.method(method_name).call() else print_general_help end end |
.kill(options = nil) ⇒ Object
7 8 9 10 |
# File 'lib/commands/kill.rb', line 7 def Commands.kill(=nil) ProcTable.ps().find_all{|p| p.comm =~ /p4d/} .each{|p| Process.kill('TERM', p.pid)} end |
.print_download_help ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/commands/download.rb', line 37 def Commands.print_download_help puts " p4util download [p4d|p4api]\n\n Downloads one of the following utilities (in lieu of an installer) into\n a local work/ directory.\n\n * p4d\n * p4api\n\n Will default to the latest release unless you don't know what that is.\n\n Options:\n\n --version X where X looks like the version in the ftp.perforce.com site,\n e.g., 'r14.2' instead of '2014.2'\n END\nend\n".gsub(/^ {6}/, '') |
.print_kill_help ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/commands/kill.rb', line 12 def Commands.print_kill_help puts " p4util kill\n\n Finds local p4d processes and kills them.\n\n There should be a timeout that will force kill anything that appears stuck.\n\n On unix machines, will probably use `ps -x` and 'p4d', then will send\n SIGTERM signals to each process.\n END\nend\n".gsub(/^ {6}/,'') |
.print_start_help ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/commands/start.rb', line 18 def Commands.print_start_help puts " p4util start\n\n Spawns a Perforce process in your local work/p4droot directory.\n\n If the Perforce executable does not exist, will download the binary first.\n\n Will try to set up a server log at work/server.log. It'll be fairly\n verbose by default; this is *not* intended for any kind of performance\n testing.\n END\nend\n".gsub(/^ {6}/,'') |
.spawn_p4d ⇒ Object
12 13 14 15 16 |
# File 'lib/commands/start.rb', line 12 def Commands.spawn_p4d pid = Process.spawn("#{OsUtil.p4d_path} -r #{Conventions.p4droot_dir} "+ "-v server=1 -L #{Conventions.p4d_log_path}") Process.detach(pid) end |
.start(options) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/commands/start.rb', line 4 def Commands.start() if !File.exists?(OsUtil.p4d_path) Commands.download end Conventions.init_p4droot_dir spawn_p4d end |