Class: MarkdownLint::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.toggle_list(s, to_sym = false) ⇒ Object



89
90
91
92
93
94
95
96
97
98
# File 'lib/mdl/cli.rb', line 89

def self.toggle_list(s, to_sym=false)
  parts = s.split(',')
  inc = parts.select{|p| not p.start_with?('~')}
  exc = parts.select{|p| p.start_with?('~')}.map{|p| p[1..-1]}
  if to_sym
    inc.map!{|p| p.to_sym}
    exc.map!{|p| p.to_sym}
  end
  {:include => inc, :exclude => exc}
end

Instance Method Details

#run(argv = ARGV) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/mdl/cli.rb', line 74

def run(argv=ARGV)
  parse_options(argv)
  # Load the config file if it's present
  filename = File.expand_path(config[:config_file])
  MarkdownLint::Config.from_file(filename) if File.exists?(filename)

  # Put values in the config file
  MarkdownLint::Config.merge!(config)

  # Read from stdin if we didn't provide a filename
  if cli_arguments.empty? and not config[:list_rules]
    cli_arguments << "-"
  end
end