Class: MarkdownLint::CLI
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.toggle_list(parts, to_sym = false) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/mdl/cli.rb', line 98 def self.toggle_list(parts, to_sym=false) if parts.class == String parts = parts.split(',') end 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 88 89 90 91 92 93 94 95 96 |
# File 'lib/mdl/cli.rb', line 74 def run(argv=ARGV) (argv) # Load the config file if it's present filename = File.(config[:config_file]) MarkdownLint::Config.from_file(filename) if File.exists?(filename) # Put values in the config file MarkdownLint::Config.merge!(config) # Set the correct format for any rules/tags configuration loaded from # the config file. Ideally this would probably be done as part of the # config class itself rather than here. MarkdownLint::Config[:rules] = CLI.toggle_list( MarkdownLint::Config[:rules]) unless MarkdownLint::Config[:rules].nil? MarkdownLint::Config[:tags] = CLI.toggle_list( MarkdownLint::Config[:tags], true) \ unless MarkdownLint::Config[:tags].nil? # Read from stdin if we didn't provide a filename if cli_arguments.empty? and not config[:list_rules] cli_arguments << "-" end end |