class Madman::Commands::Readme

Public Instance Methods

run() click to toggle source
# File lib/madman/commands/readme.rb, line 20
def run
  dir = args['DIR']
  basedir = Madman::Directory.new dir

  dirs = basedir.deep_list.select { |i| i.dir? }.map { |i| i.path }
  dirs.each do |dir|
    file = "#{dir}/README.md"
    
    if File.exist? file
      say "Skipping #{file}"
    else
      say "Creating !txtgrn!#{file}"
      h1 = "# #{File.basename dir}\n\n"
      File.write file, h1 unless args['--dry']
    end
  end

  say args['--dry'] ? "Done (dry mode, no changes were made)" : "Done"
end