Class: Bloc::Command::AddChapter
- Inherits:
-
Object
- Object
- Bloc::Command::AddChapter
- Defined in:
- lib/bloc/command/add_chapter.rb
Constant Summary collapse
- USAGE =
<<eos Usage: bloc add-chapter ["name"] Example: bloc add-chapter "Stacks and Queues" eos
Class Method Summary collapse
Class Method Details
.run(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# 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 == 2 name = ARGV[1] manifest = Bloc::Manifest.parse number = manifest.chapters.size + 1 manifest.add_chapter( :name => name, :markdown => "chapters/chapter#{number}.md", :command => "" ) end |