Class: Staticpress::CLI
- Inherits:
-
Thor
- Object
- Thor
- Staticpress::CLI
show all
- Includes:
- Helpers, Thor::Actions
- Defined in:
- lib/staticpress/cli.rb
Instance Method Summary
collapse
Methods included from Helpers
#config, #extensionless_basename, #extensionless_path, #hash_from_array, #hash_from_match_data, #paginate, #settings, #spider_map, #titleize
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
19
20
21
22
|
# File 'lib/staticpress/cli.rb', line 19
def initialize(*args)
super
Staticpress::Settings.set! options
end
|
Instance Method Details
#create_page(title, path = nil) ⇒ Object
63
64
65
|
# File 'lib/staticpress/cli.rb', line 63
def create_page(title, path = nil)
Staticpress::Content::Page.create config.preferred_format, title, path
end
|
#deploy ⇒ Object
116
117
118
|
# File 'lib/staticpress/cli.rb', line 116
def deploy
build and push
end
|
#fork_plugin(name, new_name = nil) ⇒ Object
73
74
75
76
77
78
79
80
81
|
# File 'lib/staticpress/cli.rb', line 73
def fork_plugin(name, new_name = nil)
source = Staticpress::Plugin.find name
destination_name = new_name ? (new_name.end_with?('.rb') ? new_name : "#{new_name}.rb") : source.basename
destination = Staticpress.blog_path + (config.plugins_path || 'plugins') + destination_name
FileUtils.mkdir_p destination.dirname
FileUtils.cp source, destination
end
|
#fork_theme(name = config.theme, new_name = name) ⇒ Object
88
89
90
91
|
# File 'lib/staticpress/cli.rb', line 88
def fork_theme(name = config.theme, new_name = name)
theme = Staticpress::Theme.new name
theme.copy_to new_name
end
|
#help(*args) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/staticpress/cli.rb', line 25
def help(*args)
general_usage = <<-USAGE
Usage:
staticpress <task> <required-argument> [option-argument] [--options...]
USAGE
puts general_usage if args.empty?
super
end
|
#list(method = :to_s) ⇒ Object
94
95
96
97
98
|
# File 'lib/staticpress/cli.rb', line 94
def list(method = :to_s)
Staticpress::Site.new.each do |content|
puts(content.respond_to?(method) ? content.send(method) : content)
end
end
|
#new(destination, name = nil) ⇒ Object
#serve ⇒ Object
106
107
108
|
# File 'lib/staticpress/cli.rb', line 106
def serve
Rack::Server.new(:config => (Staticpress.blog_path + 'config.ru').to_s, :Port => config.port).start
end
|
#version ⇒ Object
121
122
123
|
# File 'lib/staticpress/cli.rb', line 121
def version
puts "Staticpress #{Staticpress::Version}"
end
|