Class: Jekyll::Commands::Post
- Inherits:
-
Command
- Object
- Command
- Jekyll::Commands::Post
- Defined in:
- lib/jekyll/commands/post.rb
Defined Under Namespace
Classes: PostArgParser, PostFileInfo
Class Method Summary collapse
Class Method Details
.init_with_program(prog) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/jekyll/commands/post.rb', line 6 def self.init_with_program(prog) prog.command(:post) do |c| c.syntax "post NAME" c.description "Creates a new post with the given NAME" .each { |opt| c.option(*opt) } c.action { |args, | process(args, ) } end end |
.options ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jekyll/commands/post.rb', line 17 def self. [ ["extension", "-x EXTENSION", "--extension EXTENSION", "Specify the file extension"], ["layout", "-l LAYOUT", "--layout LAYOUT", "Specify the post layout"], ["force", "-f", "--force", "Overwrite a post if it already exists"], ["date", "-d DATE", "--date DATE", "Specify the post date"], ["config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"], ["timestamp_format", "--timestamp-format FORMAT", "Custom timestamp format"], ] end |
.process(args = [], options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jekyll/commands/post.rb', line 28 def self.process(args = [], = {}) config = () params = PostArgParser.new(args, , config) params.validate! post = PostFileInfo.new(params) file_creator = Compose::FileCreator.new(post, params.force?, params.source) file_creator.create! Compose::FileEditor.bootstrap(config) Compose::FileEditor.open_editor(file_creator.file_path) end |