Class: MdSpell::CLI

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/mdspell/cli.rb

Overview

Class responsible for parsing all of command line arguments.

Instance Method Summary collapse

Instance Method Details

#filesObject

List of markdown files from argument list.



59
60
61
62
63
64
65
66
67
# File 'lib/mdspell/cli.rb', line 59

def files
  cli_arguments.each_with_index do |filename, index|
    if Dir.exist?(filename)
      cli_arguments[index] = Dir["#{filename}/**/*.md"]
    end
  end
  cli_arguments.flatten!
  cli_arguments
end

#run(options) ⇒ Object

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mdspell/cli.rb', line 41

def run(options)
  raise ArgumentError, 'expected Array of command line options' unless options.is_a? Array

  # Start clean
  MdSpell::Configuration.reset

  parse_options(options)
  # Load optional config file if it's present.
  if config[:config_file]
    config_filename = File.expand_path(config[:config_file])
    MdSpell::Configuration.from_file(config_filename) if File.exist?(config_filename)
  end

  # Store command line configuration options.
  MdSpell::Configuration.merge!(config)
end