Given the provided options, execute the appropriate command.

 @return [Integer] exit status code
329852
def act_on_options(options)
      configure_logger(options)

      if options[:help]
        print_help(options)
        Sysexits::EX_OK
      elsif options[:version] || options[:verbose_version]
        print_version(options)
        Sysexits::EX_OK
      elsif options[:show_linters]
        print_available_linters
        Sysexits::EX_OK
      elsif options[:show_reporters]
        print_available_reporters
        Sysexits::EX_OK
      else
        scan_for_lints(options)
      end
    end
567285
def run_and_exit_if(opts, action, *names):
    
    for name in names:
        if name in opts:
            action()
            sys.exit(0)
757421
def nice_execute(cmd)
      puts bold("[Running] #{cmd.gsub(/^\s*/, ' ')}")
      stdout, stderr, exit_status = Open3.capture3( cmd )
      unless stdout.empty?
        stdout.each_line do |line|
          print "** [out] #{line}"
          $stdout.flush
        end
      end
      unless stderr.empty?
        stderr.each_line do |line|
          $stderr.print red("** [err] #{line}")
          $stderr.flush
        end
      end
      exit_status
    end
394712
def run!
      trace = @always_trace || false
      require_program :version, :description
      trap('INT') { abort program(:int_message) } if program(:int_message)
      trap('INT') { program(:int_block).call } if program(:int_block)
      global_option('-h', '--help', 'Display help documentation') do
        args = @args - %w(-h --help)
        command(:help).run(*args)
        return
      end
      global_option('-v', '--version', 'Display version information') do
        say version
        return
      end
      global_option('-t', '--trace', 'Display backtrace when an error occurs') { trace = true } unless @never_trace || @always_trace
      parse_global_options
      remove_global_options options, @args
      if trace
        run_active_command
      else
        begin
          run_active_command
        rescue InvalidCommandError => e
          abort "#{e}. Use --help for more information"
        rescue \
          OptionParser::InvalidOption,
          OptionParser::InvalidArgument,
          OptionParser::MissingArgument => e
          abort e.to_s
        rescue => e
          if @never_trace
            abort "error: #{e}."
          else
            abort "error: #{e}. Use --trace to view backtrace"
          end
        end
      end
    end
1236972
def command(command, options)
      options = {
          'print_command' => false,
          'failure_message' => "required command '#{command}' is not available."
      }.merge(string_keys(options))
      system_exit_on_error("which #{command}", options)
    end
414214
def execute(command, params={})
      unless params[:dry_run]
        if params[:return]
          System.execute(command, :return => true)
        else
          $stdout.puts
          System.execute(command)
        end
      end
    end
1075773
def execute_quiet(command, error_message)
      # Ladies and gentleman: More debug, please!
      puts command if @debug
      return_value = -1

      Open3.popen3(environment, command) do |_stdin, stdout, stderr, wait_thread|
        Thread.new do
          stdout.each do |line|
            @last_output << line.strip
            puts line unless @quiet
          end
        end

        Thread.new do
          stderr.each do |line|
            @last_error << line
            puts line unless @quiet
          end
        end

        _stdin.close

        return_value = wait_thread.value

        if @strict and return_value.exitstatus != 0
          dump_error_message(command)
          fail error_message
        end
      end

      puts "Program exited with status #{return_value.exitstatus}." if @debug

      return_value.exitstatus == 0
    end
911656
def execute(options = {})
      input_files = get_input_files(options)
      # we want to avoid printing the binary file
      input_files.delete_if do |file|
        File.binary?(file.gsub(/^\./, options[:base_dir]))
      end

      if input_files.empty?
        puts "No file found for your option: #{options}"
        return
      end

      to_htmls(input_files, options)
      generated_files = input_files.map { |f| "#{f}.xhtml" }
      index_file = "./index.html"
      IndexHtml.htmlify generated_files, base_dir: options[:base_dir],
                                         output:   index_file,
                                         drop_ext: true
      generated_files << index_file if options[:index]
      output_file = "vim_printer_#{File.basename(File.expand_path(options[:base_dir]))}.tar.gz"
      AgileUtils::FileUtil.tar_gzip_files(generated_files, output_file)
      AgileUtils::FileUtil.delete(generated_files)
      FileUtils.rm_rf(index_file) if options[:index]
      puts "Your output file is '#{File.absolute_path(output_file)}'"
    end
824662
def run(options)
      fail_if_right_agent_is_not_running
      check_privileges
      set_logger(options)
      missing_argument unless options.include?(:action)
      # Don't use send_command callback as it swallows exceptions by design
      res = send_command(build_cmd(options), options[:verbose], options[:timeout])

      case options[:action]
      when :get_tags
        get_tags(res, options)
      when :query_tags
        query_tags(res, options)
      when :add_tag
        add_tag(res, options)
      when :remove_tag
        remove_tag(res, options)
      else
        write_error(res)
      end
    rescue SystemExit => e
      raise e
    rescue Exception => e
      fail(e)
    end
116559
def run_and_exit(command_class):
    ''''''
    cmd = command_class(sys.argv[1:])
    if cmd.error:
        print('error: {0}'.format(cmd.error))
        sys.exit(1)
    else:
        sys.exit(cmd.run())
817698
def run
      option_parser @options
      
      # Check on include version request.
      if @options[:version].value then
	puts "#{@name}, version #{@version}"
	exit
      end

      # Check on include help request.
      if ARGV[0] == 'help' or ARGV[0] == '--help' or ARGV[0] == '-h' then
	# Help arguments apsent, well then display information about application.
	if ARGV.size == 1 then
	  puts
	  puts "*** #{@name} ***".center(80)
	  # Display about info.
	  if @about.size > 0 then
	    puts '** ABOUT:'
	    @about.each do |line|
	      puts "  #{line}"
	    end
	  end
	  # Display usage info.
	  if @usage.size > 0 then
	    puts
	    puts '** USAGE:'
	    @usage.each do |line|
	      puts "  #{line}"
	    end
	  end
	  # Display options info.
	  puts
	  puts '** OPTIONS:'
	  display_options @options
	  # Display commands info
	  if @commands.size > 0 then
	    @commands.each do |c| c.init end
	    puts
	    puts '** COMMANDS:'
	    display_commands @commands
	    puts
	    puts "For details, type: help [COMMAND]"
	  end
	  puts
	# Help arguments exist, find command in application command list.
	else
	  ARGV.delete_at( 0 )
	  cmd = command_select
	  if ARGV.size != 0 then
	    puts "fatal error: unknown command '#{ARGV[0]}'"
	    exit
	  end
	  # Display describe information on command.
	  puts
	  puts Cmdlib::Describe.outtitle( cmd.name )
	  puts "  #{cmd.brief}"
	  if cmd.details.size > 0 then
	    puts
	    puts '** DETAILS:'
	    cmd.details.each do |e|
	      puts "  #{e}"
	    end
	  end
	  if cmd.example.size > 0 then
	    puts
	    puts '** EXAMPLE:'
	    cmd.example.each do |e|
	      puts "  #{e}"
	    end
	  end
	  # Display options info.
	  if cmd.options.size > 0 then
	    puts
	    puts '** OPTIONS:'	  
	    display_options cmd.options
	  end
	  # Display commands info.
	  if cmd.subcmd.size > 0 then
	    cmd.subcmd.each do |c| c.init end
	    puts
	    puts '** SUBCOMMANDS:'
	    display_commands cmd.subcmd
	    puts
	    puts "For details, type: help #{cmd.name} [SUBCOMMAND]"
	  end
	  puts
	end
	exit
      end
      
      # Handling default command (if exist her).
      if @default != nil then
	option_excess
	if ARGV.size < @default.argnum then
	  puts "fatal error: to few arguments for programm, use <help>."
	else
	  @default.handler( @options, ARGV )
	end
	exit
      end
      
      # Handling commands.
      cmd = command_select
      if cmd == nil then
	puts "fatal error: unknown command or command miss, use <help>."
	exit
      end
      if ARGV.size < cmd.argnum then
	puts "fatal error: to few arguments for command, use: <help> <command name>."
	exit
      end
      # Scaning options fir this command
      option_parser cmd.options
      option_excess
      #cmd.init
      cmd.handler( @options, ARGV )
      exit
    end
1047041
def execute(self, *args, **kwargs):
        
        # Remove internal Django command handling machinery
        kwargs.pop('skip_checks', None)
        parent_ctx = click.get_current_context(silent=True)
        with self.make_context('', list(args), parent=parent_ctx) as ctx:
            # Rename kwargs to to the appropriate destination argument name
            opt_mapping = dict(self.map_names())
            arg_options = {opt_mapping.get(key, key): value
                           for key, value in six.iteritems(kwargs)}

            # Update the context with the passed (renamed) kwargs
            ctx.params.update(arg_options)

            # Invoke the command
            self.invoke(ctx)
512397
def open
      status = system(env, *Shellwords.split(command_path))
      return status if status
      fail CommandInvocationError,
           "`#{command_path}` failed with status: #{$? ? $?.exitstatus : nil}"
    end
501467
def execute(*)
      file, line, = caller.first.split(":")
      colors = SSHKit::Color.new($stderr)
      $stderr.puts colors.colorize("Warning: `execute' should be wrapped in an `on' scope in #{file}:#{line}.", :red)
      $stderr.puts
      $stderr.puts "  task :example do"
      $stderr.puts colors.colorize("    on roles(:app) do", :yellow)
      $stderr.puts "      execute 'whoami'"
      $stderr.puts colors.colorize("    end", :yellow)
      $stderr.puts "  end"
      $stderr.puts
      raise NoMethodError, "undefined method `execute' for main:Object"
    end
194644
def execute(args = nil)
      execute_without_airbrake(args)
    rescue Exception => ex
      notify_airbrake(ex, args)
      raise ex
    end
355453
def run(cmd_type, command = nil, options = {}, &block)
      command        = cmd_type.to_s if command.nil?
      heroku_options = (options.delete(:heroku) || {}).map do |k,v|
        arg = "--#{k.to_s.shellescape}"
        arg << "=#{v.to_s.shellescape}" unless v.nil?
        arg
      end.join(" ")
      heroku_command = "heroku run -a #{name} #{heroku_options} --exit-code -- #{command}"
      bundle_exec do
        if block_given?
          ReplRunner.new(cmd_type, heroku_command, options).run(&block)
        else
          `#{heroku_command}`
        end
      end
    end
869754
def exec_ignore_code(command, options = {}, &block)
      options = (options || {}).merge(retrieve_exit_code: false, on_non_zero_exit_code: :ignore)
      exec command, options, &block
    end