Class: Bloc::Command::AddChapter

Inherits:
Object
  • Object
show all
Defined in:
lib/bloc/command/add_chapter.rb

Constant Summary collapse

USAGE =
<<eos
Usage:

bloc add-chapter <"name"> <"markdown"> <"command">

Example:

bloc add-chapter "Stacks and Queues" "markdown/chapter4.md" "rspec spec -t ch4 -f j"
eos

Class Method Summary collapse

Class Method Details

.run(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bloc/command/add_chapter.rb', line 12

def self.run(*args)
  raise Bloc::Manifest::MANIFEST_NOT_FOUND unless File.exists?(Bloc::Manifest::MANIFEST_PATH)
  raise USAGE unless ARGV.size == 3
  name = ARGV[1] || "New Chapter"
  markdown = ARGV[2] || ""
  command = ARGV[3] || ""

  manifest = Bloc::Manifest.parse
  manifest.add_chapter(
    :name => name,
    :markdown => markdown,
    :command => command
  )
end