module P4Tools

Constants

PROJECT_NAME
VERSION

Public Class Methods

connection() click to toggle source

@return [P4]

# File lib/p4_tools.rb, line 40
def self.connection
  @p4
end
run(args=ARGV) click to toggle source

@param [Array<String>] args @return [void]

# File lib/p4_tools.rb, line 14
def self.run(args=ARGV)
  entries = CommandParser.new(args).parse
  global_arguments = entries.shift.arguments

  create_perforce_connection

  begin
    run_commands(entries)
  ensure
    @p4.disconnect
  end
end
set_options(opts) click to toggle source

@param [CommandOptions] opts @return [void]

# File lib/p4_tools.rb, line 29
def self.set_options(opts)
  opts.set do
    help 'Simple command line tool to run custom perforce actions through subcommands.'
    help 'For more information, please check the help page of the subcommand.'
    help ''
    help "Available subcommands are:\n  #{SUB_COMMANDS.join("\n  ")}"
    help ''
  end
end

Private Class Methods

create_perforce_connection() click to toggle source

@return [void]

# File lib/p4_tools.rb, line 49
def create_perforce_connection
  @p4 = P4.new
  @p4.connect
end
run_commands(entries) click to toggle source

@param [Hash<Module, Hash<Symbol, Object>>] commands @return [void]

# File lib/p4_tools.rb, line 56
def run_commands(entries)
  entries.each do |entry|
    command = entry.command
    arguments = entry.arguments

    command.run(arguments)
  end
end