openstudiocore/src/cli/openstudio_cli.rb
# Checks to see if it should print the main help, and if not parses the command into a class and executes it
Checks to see if it should print the main help, and if not parses the command into a class and executes it
Checks to see if it should print the main help and if not parses the command into a class and executes it
def execute
    $logger.debug "Main arguments are #{$main_args}"
    $logger.debug "Sub-command is #{$sub_command}"
    $logger.debug "Sub-arguments are #{$sub_args}"
    if $main_args.include?('-h') || $main_args.include?('--help')
      help
      return 0
    end
    if !parse_main_args($main_args)
      help
      return 1
    end
    if !$eval_cmds.empty?
      $eval_cmds.each do |cmd|
        $logger.debug "Executing cmd: #{cmd}"
        eval(cmd)
      end
      if $sub_command
        $logger.warn "Evaluate mode detected, ignoring sub_command #{$sub_command}"
        return 0
      end
      return 0
    end
    command_plugin = nil
    if $sub_command
      command_plugin = command_list[$sub_command.to_sym]
    end
    if !command_plugin || !$sub_command
      help
      return 1
    end
    command_class = command_plugin[0].call
    $logger.debug("Invoking command class: #{command_class} #{$sub_args.inspect}")
    result = 0
    begin
      result = command_class.new.execute($sub_args)
    rescue Interrupt
      $logger.error '?'
      result = 1
    end
    result = 0 unless result.is_a?(Fixnum)
    result
  end
def execute $logger . debug "Main arguments are #{$main_args}" $logger . debug "Sub-command is #{$sub_command}" $logger . debug "Sub-arguments are #{$sub_args}" if $main_args . include? ( '-h' ) || $main_args . include? ( '--help' ) help return 0 end if ! parse_main_args ( $main_args ) help return 1 end if ! $eval_cmds . empty? $eval_cmds . each do | cmd | $logger . debug "Executing cmd: #{cmd}" eval ( cmd ) end if $sub_command $logger . warn "Evaluate mode detected, ignoring sub_command #{$sub_command}" return 0 end return 0 end command_plugin = nil if $sub_command command_plugin = command_list [ $sub_command . to_sym ] end if ! command_plugin || ! $sub_command help return 1 end command_class = command_plugin [ 0 ] . call $logger . debug ( "Invoking command class: #{command_class} #{$sub_args.inspect}" ) result = 0 begin result = command_class . new . execute ( $sub_args ) rescue Interrupt $logger . error '?' result = 1 end result = 0 unless result . is_a? ( Fixnum ) result end
Checks to see if it should print the main help, and if not parses the command into a class and executes it
Checks to see if it should print the main help and if not parses the command into a class and executes it
# Help is next in short-circuiting everything. Print # the help and exit. # -e commands detected # If we reached this far then we must have a command. If not, # then we also just print the help and exit. # Initialize and execute the command class, returning the exit status.