lib/sapos/print/cli.rb in sapos-print-1.0.7 vs lib/sapos/print/cli.rb in sapos-print-1.0.8

- old
+ new

@@ -8,12 +8,18 @@ def setup info config = {} url = ask("Configuration URL") - response = RestClient.get(url) - data = JSON.parse(response) + if url.eql?('manual') + data = {} + data["channel"] = ask("Channel:") + data["key"] = ask("Queue Key") + else + response = RestClient.get(url) + data = JSON.parse(response) + end config_file = "#{Sapos::Print.app_directory}/config.yml" user_id = nil if File.exist?(config_file) template = ERB.new(File.read(config_file)) @@ -36,20 +42,23 @@ say "Configuration Saved! Cheers" end end desc "start", "run service" + option :verbose, type: :boolean def start info config = Sapos::Print.config - puts ["Q=#{config.q.to_s}", "Printer=#{config.printer.to_s}", "Adapter=#{config.adapter.to_s}", "Interface=#{config.interface}"].join("\n") + puts ["Q=#{config.q.to_s}", "Printer=#{config.printer.to_s}", "Adapter=#{config.adapter.to_s}", "Interface=#{config.interface}"].join(";") print_dir = File.join(Sapos::Print.app_directory, 'print') if File.exists?(print_dir) - FileUtils.rm_rf Dir.glob("#{print_dir}/*") + Dir.glob("#{print_dir}/*.print").each do |x| + FileUtils.rm_rf(x) if File.ctime(x) < Time.now - 3600 + end end - + config.verbose = options[:verbose] Sapos::Print::QReader.printer_config = config Sapos::Print::QReader.verbose = options[:verbose] Sapos::Print::QReader.run! end @@ -59,9 +68,10 @@ config = Sapos::Print.config printer = Printer.new(config) printer.print(document: "This is a test\nprint page\nwithno special commands", document_number: "test", print_control: true) end + desc "windows_test_print", "test printer" def windows_test_print info filename = "test.print" \ No newline at end of file