Class: Madman::Commands::Readme

Inherits:
MisterBin::Command
  • Object
show all
Includes:
Colsole
Defined in:
lib/madman/commands/readme.rb

Instance Method Summary collapse

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/madman/commands/readme.rb', line 20

def run
  dir = args['DIR']
  basedir = Madman::Directory.new dir, 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