Class: SyntaxTree::CLI::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/cli.rb

Overview

This represents all of the options that can be passed to the CLI. It is responsible for parsing the list and then returning the file paths at the end.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(print_width: DEFAULT_PRINT_WIDTH) ⇒ Options

Returns a new instance of Options.



292
293
294
295
296
297
298
# File 'lib/syntax_tree/cli.rb', line 292

def initialize(print_width: DEFAULT_PRINT_WIDTH)
  @ignore_files = ""
  @plugins = []
  @print_width = print_width
  @scripts = []
  @target_ruby_version = nil
end

Instance Attribute Details

#ignore_filesObject (readonly)

Returns the value of attribute ignore_files.



286
287
288
# File 'lib/syntax_tree/cli.rb', line 286

def ignore_files
  @ignore_files
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



286
287
288
# File 'lib/syntax_tree/cli.rb', line 286

def plugins
  @plugins
end

Returns the value of attribute print_width.



286
287
288
# File 'lib/syntax_tree/cli.rb', line 286

def print_width
  @print_width
end

#scriptsObject (readonly)

Returns the value of attribute scripts.



286
287
288
# File 'lib/syntax_tree/cli.rb', line 286

def scripts
  @scripts
end

#target_ruby_versionObject (readonly)

Returns the value of attribute target_ruby_version.



286
287
288
# File 'lib/syntax_tree/cli.rb', line 286

def target_ruby_version
  @target_ruby_version
end

Instance Method Details

#parse(arguments) ⇒ Object

TODO: This function causes a couple of side-effects that I really don’t like to have here. It mutates the global state by requiring the plugins, and mutates the global options hash by adding the target ruby version. That should be done on a config-by-config basis, not here.



304
305
306
# File 'lib/syntax_tree/cli.rb', line 304

def parse(arguments)
  parser.parse!(arguments)
end