exe/mnogootex in mnogootex-0.2.1 vs exe/mnogootex in mnogootex-1.0.0
- old
+ new
@@ -1,96 +1,6 @@
#!/usr/bin/env ruby
-# coding: utf-8
+# frozen_string_literal: true
require 'mnogootex'
-
-# require 'pathname'
-
-# target = ARGV[0]
-# target_path = File.expand_path target
-# cfg = Mnogootex::Configuration.new
-# cfg.load target_path
-
-require 'tmpdir'
-require 'fileutils'
-require 'open3'
-
-require 'colorize'
-
-target = ARGV[0]
-
-
-raise "No parameters given." if ARGV.length.zero?
-
-if ARGV.length == 3
- raise "Unknown command." unless %w{show view open}.include? ARGV[1].downcase
- job = Mnogootex::Job.new cls: ARGV[2], target: File.expand_path(target)
- pdf = Dir.glob("#{job.tmp_dirname}/*.pdf").first
- raise "PDF non esiste." unless File.exist? pdf
- `command -v open >/dev/null && open #{pdf} || xdg-open #{pdf}`
- exit
-end
-
-puts "Mnogootex v#{Mnogootex::VERSION}"
-
-main_path = File.expand_path(target)
-main_basename = File.basename main_path
-main_dirname = File.dirname main_path
-
-cfg = Mnogootex::Configuration.new
-cfg.load main_dirname
-
-raise "File non esiste." unless File.exist? main_path
-
-@documentclasses = cfg['compile_with']
-
-$jobs = []
-$threads = []
-$draw_threads = []
-
-$threads = []
-
-$anim = cfg['animation'].freeze
-
-STDOUT.sync = true
-
-def draw_status
- icons = $jobs.map do |j|
- icon = $anim[j.ticks % $anim.length]
- case j.thread.status
- when 'sleep', 'run', 'aborting'
- icon.yellow
- when false, nil # exited (normally or w/ error)
- j.success? ? icon.green : icon.red
- end
- end
- print ' Jobs: ' + icons.join + "\r"
-end
-
-draw_status
-
-@documentclasses.each_with_index do |cls, index|
- job = Mnogootex::Job.new cls: cls, target: main_path
- job.setup
- job.run
-
- $jobs << job
-
- $draw_threads << job.tick_thread
- $threads << job.thread
-end
-
-$threads.map(&:join)
-$draw_threads.map(&:join)
-
-puts
-
-puts ' Details:'
-$jobs.each do |job|
- if job.success?
- puts ' ' + "✔".green + ' ' + File.basename(job.cls)
- else
- puts ' ' + "✘".red + ' ' + File.basename(job.cls)
- puts job.log[2..-2].join.gsub(/^/,' '*6).chomp.red
- end
-end
+Mnogootex::CLI.start ARGV