lib/sapos/print/cli.rb in sapos-print-1.0.10 vs lib/sapos/print/cli.rb in sapos-print-1.1.0

- old
+ new

@@ -1,21 +1,21 @@ require "io/console" module Sapos module Print include Thor::Actions class CLI < Thor - + desc "setup", "Setup Wizard" def setup info config = {} - url = ask("Configuration URL") + url = ask("URL de Configuración: ") if url.eql?('manual') data = {} - data["channel"] = ask("Channel:") - data["key"] = ask("Queue Key") + data["channel"] = ask("Canal:") + data["key"] = ask("Llave de la Cola:") else response = RestClient.get(url) data = JSON.parse(response) end @@ -29,20 +29,25 @@ user_id = SecureRandom.uuid if user_id.nil? config[:q] = data["channel"] config[:key] = data["key"] - config[:printer] = ask("Printer Name: ") - config[:adapter] = ask("Printer Adapter: ", limited_to: ["console", "cups", "windows"]) + config[:printer] = ask("Nombre de la impresora default: ") + config[:adapter] = ask("Adaptador: ", limited_to: ["console", "cups", "windows"]) config[:interface] = ask("Interface", limited_to: ["text", "escp"]) config[:user_id] = user_id config[:duplicate_control] = ask("¿Control Duplicados por MSGID?", limited_to: ["si", "no"]) + config[:printers] = [config[:printer]] - if yes?("Are you sure that you want to write the configuration file?") + while yes?("¿Tiene impresoras adicionales?") + name = ask("Nombre de la impresora adicional: ") + config[:printers] << name + end + if yes?("¿Esta seguro que desea guardar la configuración?") Sapos::Print::Configuration.write(config) ap config - say "Configuration Saved! Cheers" + say "La configuración ha sido guardada!" end end desc "start", "run service" option :verbose, type: :boolean @@ -62,12 +67,20 @@ Sapos::Print::QReader.verbose = options[:verbose] Sapos::Print::QReader.run! end desc "print", "demo print" + option :printer_name, type: :string def print info config = Sapos::Print.config + printer_name = options[:printer_name] + if printer_name.present? + if config.printers.any? && config.printers.include?(printer_name) + config.printer = printer_name + end + end + puts "Printing to: #{config.printer}" 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" \ No newline at end of file