Class: Evilution::CLI::Parser Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: FileArgs Classes: CommandExtractor, OptionsBuilder, StdinReader

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdin: $stdin) ⇒ Parser

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Parser.



6
7
8
9
10
11
12
13
14
15
# File 'lib/evilution/cli/parser.rb', line 6

def initialize(argv, stdin: $stdin)
  @argv = argv.dup
  @stdin = stdin
  @options = {}
  @files = []
  @line_ranges = {}
  @command = :run
  @parse_error = nil
  @stdin_error = nil
end

Instance Method Details

#parseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/evilution/cli/parser.rb', line 17

def parse
  extract_command
  return build_parsed_args if @command == :parse_error

  preprocess_flags
  remaining = OptionsBuilder.build(@options).parse!(@argv)
  parsed_paths = FileArgs.parse(remaining)
  @files = parsed_paths.files
  @line_ranges = parsed_paths.ranges
  read_stdin_files if @options.delete(:stdin) && %i[run subjects].include?(@command)
  build_parsed_args
end