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



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

def run
  basedir = Madman::Directory.new args['DIR']

  dirs = basedir.deep_list.select(&:dir?).map(&:path)
  dirs.each do |dir|
    file = "#{dir}/README.md"

    if File.exist? file
      say "Skipping #{file}"
    else
      say "Creating g`#{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