lib/mnogootex/cli.rb in mnogootex-1.0.1 vs lib/mnogootex/cli.rb in mnogootex-1.1.0
- old
+ new
@@ -8,11 +8,11 @@
require 'mnogootex/job/porter'
require 'mnogootex/cfg'
module Mnogootex
class CLI < Thor
- IS_MNOGOO = (ENV['IS_MNOGOO'] == 'true').freeze
+ IS_MNOGOO = (ENV['IS_MNOGOO'] == 'true')
def self.basename
IS_MNOGOO ? 'mnogoo' : super
end
@@ -34,10 +34,11 @@
desc 'clobber',
'Clean up all temporary files'
def clobber
# NOTE: this is a tad slow - using shell would improve that
+ # TODO: this does not account for custom work_path
tmp_dir = Pathname.new(Dir.tmpdir).join('mnogootex')
tmp_dir_size = Mnogootex::Utils.humanize_bytes Mnogootex::Utils.dir_size(tmp_dir)
print "Freeing up #{tmp_dir_size}... "
FileUtils.rm_r tmp_dir, secure: true if tmp_dir.directory?
puts 'Done.'
@@ -52,16 +53,16 @@
end
desc 'dir [JOB] [MAIN]',
'Print dir of JOB (or source) for MAIN (or inferred) document'
def dir(*args)
- jobs, main, = Mnogootex::Cfg.recombobulate(*args)
+ jobs, main, cfg = Mnogootex::Cfg.recombobulate(*args)
if jobs.empty?
puts main.dirname
else
- jobs.map! { |hid| Mnogootex::Job::Porter.new hid: hid, source_path: main }
+ jobs.map! { |hid| Mnogootex::Job::Porter.new hid: hid, source_path: main, work_path: cfg['work_path'] }
jobs.map!(&:target_dir)
puts jobs
end
end
@@ -69,10 +70,10 @@
'Print PDF path of each (or every) JOB for MAIN (or inferred) document'
def pdf(*args)
jobs, main, cfg = Mnogootex::Cfg.recombobulate(*args)
jobs = cfg['jobs'] if jobs.empty?
- jobs.map! { |hid| Mnogootex::Job::Porter.new hid: hid, source_path: main }
+ jobs.map! { |hid| Mnogootex::Job::Porter.new hid: hid, source_path: main, work_path: cfg['work_path'] }
jobs.map! { |porter| porter.target_path.sub_ext('.pdf') }
puts jobs
end
end
end