Class: Jekyll::Commands::ComposeCommand
- Inherits:
-
Command
- Object
- Command
- Jekyll::Commands::ComposeCommand
- Defined in:
- lib/jekyll/commands/compose.rb
Defined Under Namespace
Classes: ComposeCommandArgParser, ComposeCommandFileInfo
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/compose.rb', line 6 def self.init_with_program(prog) prog.command(:compose) do |c| c.syntax "compose NAME" c.description "Creates a new document 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 27 28 |
# File 'lib/jekyll/commands/compose.rb', line 17 def self. [ ["extension", "-x EXTENSION", "--extension EXTENSION", "Specify the file extension"], ["layout", "-l LAYOUT", "--layout LAYOUT", "Specify the document layout"], ["force", "-f", "--force", "Overwrite a document if it already exists"], ["date", "-d DATE", "--date DATE", "Specify the document date"], ["collection", "-c COLLECTION", "--collection COLLECTION", "Specify the document collection"], ["post", "--post", "Create a new post (default)"], ["draft", "--draft", "Create a new draft"], ["config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"], ] end |
.process(args = [], options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jekyll/commands/compose.rb', line 30 def self.process(args = [], = {}) config = () params = ComposeCommandArgParser.new(args, , config) params.validate! document = ComposeCommandFileInfo.new(params) file_creator = Compose::FileCreator.new(document, params.force?, params.source) file_creator.create! Compose::FileEditor.bootstrap(config) Compose::FileEditor.open_editor(file_creator.file_path) end |