Class: Wordless::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, CLIHelper
Defined in:
lib/wordless/cli.rb

Constant Summary collapse

@@lib_dir =
File.expand_path(File.dirname(__FILE__))

Instance Method Summary collapse

Methods included from CLIHelper

#add_git_repo, #download, #error, #git_installed?, #success, #unzip, #warning

Instance Method Details

#compileObject



67
68
69
70
71
72
73
# File 'lib/wordless/cli.rb', line 67

def compile
  if system "php #{File.join(@@lib_dir, 'compile_assets.php')}"
    success "Compiled static assets."
  else
    error "Couldn't compile static assets."
  end
end

#installObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wordless/cli.rb', line 32

def install
  unless git_installed?
    error "Git is not available. Please install git."
    return
  end

  unless File.directory? 'wp-content/plugins'
    error "Directory 'wp-content/plugins' not found. Make sure you're at the root level of a WordPress installation."
    return
  end

  if add_git_repo wordless_repo, 'wp-content/plugins/wordless'
    success "Installed Wordless plugin."
  else
    error "There was an error installing the Wordless plugin."
  end
end

#new(name) ⇒ Object



24
25
26
27
28
29
# File 'lib/wordless/cli.rb', line 24

def new(name)
  WordPressTools::CLI.new.invoke('new', [name], :bare => true, :locale => options['locale'])
  Dir.chdir(name)
  Wordless::CLI.new.invoke(:install)
  invoke('theme', [name])
end

#theme(name) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/wordless/cli.rb', line 51

def theme(name)
  unless File.directory? 'wp-content/themes'
    error "Directory 'wp-content/themes' not found. Make sure you're at the root level of a WordPress installation."
    return
  end
  
  # Run PHP helper script
  if system "php #{File.join(@@lib_dir, 'theme_builder.php')} #{name}"
    success "Created a new Wordless theme in 'wp-content/themes/#{name}'."
  else
    error "Couldn't create Wordless theme."
    return
  end
end