class Bashly::Commands::Init

Public Instance Methods

run() click to toggle source
# File lib/bashly/commands/init.rb, line 14
def run
  if Dir.exist? target_dir and !Dir.empty? target_dir
    raise InitError, "Directory !txtgrn!#{target_dir}!txtrst! already exists and is not empty"
  end
  Dir.mkdir target_dir unless Dir.exist? target_dir
  File.write "#{target_dir}/bashly.yml", yaml_content
  say "created !txtgrn!#{target_dir}/bashly.yml"
  say "run !txtpur!bashly generate!txtrst! to create the bash script"
end

Private Instance Methods

target_dir() click to toggle source
# File lib/bashly/commands/init.rb, line 38
def target_dir
  @target_dir ||= Settings.source_dir
end
yaml_content() click to toggle source
# File lib/bashly/commands/init.rb, line 26
def yaml_content
  @yaml_content ||= yaml_content!
end
yaml_content!() click to toggle source
# File lib/bashly/commands/init.rb, line 30
def yaml_content!
  if args['--minimal']
    File.read asset('templates/minimal.yml')
  else
    File.read asset('templates/bashly.yml')
  end
end