Class: Trace2::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/trace2/options.rb

Overview

Defines and returns options for Trace2’s runner, given the arguments that were passed rubocop:disable Metrics/ClassLength

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option_parser: Trace2::OptionParser.new, kernel: Kernel) ⇒ Options

rubocop:disable Metrics/MethodLength



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/trace2/options.rb', line 13

def initialize(option_parser: Trace2::OptionParser.new, kernel: Kernel)
  @options = default_options
  @kernel = kernel
  @option_parser = option_parser
  options_banner
  help_option
  version_option
  filter_option
  output_path_option
  type_option
  format_option
  manual_option
end

Class Method Details

.parse(args) ⇒ Object



8
9
10
# File 'lib/trace2/options.rb', line 8

def self.parse(args)
  new.parse(args)
end

Instance Method Details

#parse(args) ⇒ Object

rubocop:enable Metrics/MethodLength



28
29
30
31
32
33
34
35
36
37
# File 'lib/trace2/options.rb', line 28

def parse(args)
  trace2, executable_args = @option_parser.split_executables(args)
  executable = executable_args.shift

  @option_parser.parse(trace2)

  raise_missing_executable if executable.nil?

  @options.merge(executable: executable, args: executable_args)
end