Class: Verku::Cli
- Inherits:
-
Thor
- Object
- Thor
- Verku::Cli
- Defined in:
- lib/verku/cli.rb
Constant Summary collapse
- FORMATS =
%w[pdf draft proof html epub mobi txt]
Class Method Summary collapse
Instance Method Summary collapse
- #create(path) ⇒ Object
- #export ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Cli
constructor
A new instance of Cli.
- #move(oid, nid) ⇒ Object
- #pdf ⇒ Object
- #stats ⇒ Object
- #trash(scene_id) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Cli
Returns a new instance of Cli.
12 13 14 15 16 17 |
# File 'lib/verku/cli.rb', line 12 def initialize(args = [], = {}, config = {}) if (config[:current_task] || config[:current_command]).name == "new" && args.empty? raise Error, "The e-Book path is required. For details run: verku help new" end super end |
Class Method Details
.exit_on_failure? ⇒ Boolean
9 10 11 |
# File 'lib/verku/cli.rb', line 9 def self.exit_on_failure? true end |
Instance Method Details
#create(path) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/verku/cli.rb', line 21 def create(path) say "Verku -- A Million Monkeys Writing Your Masterpiece." generator = Generator.new generator.destination_root = path.squish.gsub(' ','-') generator.invoke_all end |
#export ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/verku/cli.rb', line 32 def export inside_ebook! if [:only] && !FORMATS.include?([:only]) raise Error, "The --only option need to be one of: #{FORMATS.join(", ")}" end Verku::Exporter.run(root_dir, ) end |
#move(oid, nid) ⇒ Object
68 69 70 71 |
# File 'lib/verku/cli.rb', line 68 def move(oid,nid) s = Structure.new(root_dir) s.move(oid,nid) end |
#pdf ⇒ Object
41 42 43 44 |
# File 'lib/verku/cli.rb', line 41 def pdf inside_ebook! Verku::Exporter.run(root_dir, {:only => 'pdf'}) end |
#stats ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/verku/cli.rb', line 53 def stats inside_ebook! stats = Verku::Stats.new(root_dir) say [ # "Chapters: #{stats.chapters}", "Goal: #{sprintf("%7d", stats.target)}", "Words: #{sprintf("%7d", stats.words)}", " -------", "Remain: #{sprintf("%7d", stats.remaining)}", "Progress: #{sprintf("%7d", stats.today)}" ].join("\n") end |
#trash(scene_id) ⇒ Object
73 74 75 76 |
# File 'lib/verku/cli.rb', line 73 def trash(scene_id) s = Structure.new(root_dir) s.trash(scene_id) end |