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