Class: Mnogootex::CLI

Inherits:
Thor show all
Defined in:
lib/mnogootex/cli.rb

Constant Summary collapse

IS_MNOGOO =
(ENV['IS_MNOGOO'] == 'true').freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.basenameObject



15
16
17
# File 'lib/mnogootex/cli.rb', line 15

def self.basename
  IS_MNOGOO ? 'mnogoo' : super
end

Instance Method Details

#cd(*args) ⇒ Object



21
# File 'lib/mnogootex/cli.rb', line 21

def cd(*args); end

#clobberObject



37
38
39
40
41
42
43
44
# File 'lib/mnogootex/cli.rb', line 37

def clobber
  # NOTE: this is a tad slow - using shell would improve that
  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.'
end

#dir(*args) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/mnogootex/cli.rb', line 56

def dir(*args)
  jobs, main, = 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!(&:target_dir)
    puts jobs
  end
end

#go(*args) ⇒ Object



48
49
50
51
52
# File 'lib/mnogootex/cli.rb', line 48

def go(*args)
  _, main, cfg = Mnogootex::Cfg.recombobulate(*args)
  cfg = Mnogootex::Cfg::DEFAULTS.merge cfg
  Mnogootex::Job::Warden.new(source: main, configuration: cfg).start
end

#mnogooObject



31
32
33
# File 'lib/mnogootex/cli.rb', line 31

def mnogoo
  puts Pathname.new('mnogoo.sh')
end

#open(*args) ⇒ Object



25
# File 'lib/mnogootex/cli.rb', line 25

def open(*args); end

#pdf(*args) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/mnogootex/cli.rb', line 70

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! { |porter| porter.target_path.sub_ext('.pdf') }
  puts jobs
end