Class: Vines::Web::Command::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/vines/web/command/init.rb

Instance Method Summary collapse

Instance Method Details

#run(opts) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vines/web/command/init.rb', line 5

def run(opts)
  raise 'vines-web init <domain>' unless opts[:args].size == 1
  raise 'vines gem required: gem install vines' unless vines_installed?

  domain = opts[:args].first.downcase
  base = File.expand_path(domain)

  `vines init #{domain}` unless File.exists?(base)

  web = File.expand_path('../../../../../public', __FILE__)
  FileUtils.cp_r(Dir.glob("#{web}/*"), "#{domain}/web")

  puts "Web assets installed: #{domain}"
  puts "Run 'cd #{domain} && vines start' to begin"

  `type open && open http://localhost:5280/`
end