Class: Ruboclean::CliArguments

Inherits:
Object
  • Object
show all
Defined in:
lib/ruboclean/cli_arguments.rb

Overview

Reads command line arguments and exposes corresponding reader methods

Constant Summary collapse

FLAG_DEFAULTS =
{
  "--stdin" => false,
  "--output" => nil,
  "--silent" => false,
  "--preserve-comments" => false,
  "--preserve-paths" => false,
  "--verify" => false
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(command_line_arguments = []) ⇒ CliArguments

Returns a new instance of CliArguments.



15
16
17
# File 'lib/ruboclean/cli_arguments.rb', line 15

def initialize(command_line_arguments = [])
  @command_line_arguments = Array(command_line_arguments)
end

Instance Method Details

#inputObject



19
20
21
# File 'lib/ruboclean/cli_arguments.rb', line 19

def input
  @input ||= find_input
end

#outputObject



27
28
29
# File 'lib/ruboclean/cli_arguments.rb', line 27

def output
  flag_arguments.fetch("--output")
end

#preserve_comments?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/ruboclean/cli_arguments.rb', line 35

def preserve_comments?
  flag_arguments.fetch("--preserve-comments")
end

#preserve_paths?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ruboclean/cli_arguments.rb', line 39

def preserve_paths?
  flag_arguments.fetch("--preserve-paths")
end

#silent?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ruboclean/cli_arguments.rb', line 31

def silent?
  flag_arguments.fetch("--silent")
end

#stdin?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ruboclean/cli_arguments.rb', line 23

def stdin?
  flag_arguments.fetch("--stdin")
end

#verify?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ruboclean/cli_arguments.rb', line 43

def verify?
  flag_arguments.fetch("--verify")
end