Class: Conv::CLI
- Inherits:
-
Thor
- Object
- Thor
- Conv::CLI
- Defined in:
- lib/ffc/cli.rb
Instance Method Summary collapse
-
#convert(*inputs, output) ⇒ Object
option :arguments, type: :string, aliases: ‘-a’, desc: “Set arguments to provide a certain command such as ‘-O2’”.
- #index(input) ⇒ Object
- #list(*inputs) ⇒ Object
- #rehash ⇒ Object
- #sort(input) ⇒ Object
Instance Method Details
#convert(*inputs, output) ⇒ Object
option :arguments, type: :string, aliases: ‘-a’, desc: “Set arguments to provide a certain command such as ‘-O2’”
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ffc/cli.rb', line 23 def convert(*inputs, output) # Define commands as a method. prompt = TTY::Prompt.new(interrupt: :exit) items = Conv.new.find_item(inputs, output, input_format=input_format, output_format=output_format, package_manager: [:package_manager]) candidate = items[0] if items.empty? prompt.error "No candidates." inputs << output list(*inputs) if ![:hidelist] else if [:confirm]#interactive] candidate = prompt.select("Choose commands (To cancel, press CTRL+C)", items) #do |item| end prompt.ok candidate.cmd(inputs, output) unless [:quiet] return if ![:overwrite] && !ask_overwrite(output) || [:dryrun] status, stdout, stderr = candidate.run!(inputs, output, [:arguments]) prompt.ok stdout prompt.error stderr if status != 0 if [:autobrew] || !prompt.no?("Install " + candidate.package + " with package manager? (" + candidate.brew_command + ")") status, stdout, stderr = candidate.brew! prompt.say stdout prompt.error stderr if status == 0 status, stdout, stderr = candidate.run!(inputs, output) prompt.ok stdout prompt.error stderr end end else Conv.update!(candidate) unless [:onetime] end end end |
#index(input) ⇒ Object
113 114 115 |
# File 'lib/ffc/cli.rb', line 113 def index(input) # end |
#list(*inputs) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ffc/cli.rb', line 67 def list(*inputs) prompt = TTY::Prompt.new(interrupt: :exit) items = Conv.new.list(inputs, input_format=input_format, package_manager: [:package_manager]) #p inputs,items if items.empty? prompt.error "No candidates." return end if ![:showonly] candidate = prompt.select("Choose commands (To cancel: CTRL+C)", items) #do |item| option = [:add_prefix] ? :prefix : :exchange output = candidate.generate_output_filename(inputs[0], option) return if ![:overwrite] && !ask_overwrite(output) || [:dryrun] prompt.ok candidate.cmd(inputs, output) unless [:quiet] status, stdout, stderr = candidate.run!(inputs, output)#(options[:autobrew]) prompt.say stdout prompt.error stderr if status != 0 if [:autobrew] || !prompt.no?("Install " + candidate.package + " with package manager? (" + candidate.brew_command + ")") status, stdout, stderr = candidate.brew! prompt.say stdout prompt.error stderr if status == 0 status, stdout, stderr = candidate.run!(inputs, output) prompt.say stdout prompt.error stderr end end else Conv.update!(candidate) unless [:onetime] end else prompt.say items.join("") end end |
#sort(input) ⇒ Object
107 108 109 |
# File 'lib/ffc/cli.rb', line 107 def sort(input) # end |