Class: Octopress::Publish
Class Method Summary
collapse
Methods inherited from Command
inherited, #init_with_program, subclasses
Class Method Details
.init_with_program(p) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/octopress/commands/publish.rb', line 3
def self.init_with_program(p)
p.command(:publish) do |c|
c.syntax 'publish <DRAFT> [options]'
c.description 'Convert a draft to a normal published post.'
c.option 'date', '--date DATE', 'String that is parseable by Time#parse. (default: Time.now.iso8601)'
c.option 'force', '--force', 'Overwrite file if it already exists'
c.option 'dir', '--dir DIR', 'Create post at _posts/DIR/.'
CommandHelpers.add_common_options c
c.action do |args, options|
abort "You didn't specify a post." if args.empty?
options['path'] = args.first
options['type'] = 'post from draft'
if !options['path']
abort "Publish failed: Please provide a path or a search string to select your post."
end
if File.exist?(options['path'])
publish_post(options)
else
options['path'] = CommandHelpers.select_posts(options['path'], 'publish')
publish_post(options)
end
end
end
end
|
.publish_post(options) ⇒ Object
31
32
33
|
# File 'lib/octopress/commands/publish.rb', line 31
def self.publish_post(options)
Draft.new(Octopress.site(options), options).publish
end
|