Class: Legion::CLI::AbsorbCommand
- Inherits:
-
Thor
- Object
- Thor
- Legion::CLI::AbsorbCommand
- Defined in:
- lib/legion/cli/absorb_command.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
8 9 10 |
# File 'lib/legion/cli/absorb_command.rb', line 8 def self.exit_on_failure? true end |
Instance Method Details
#list ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/cli/absorb_command.rb', line 34 def list out = formatter patterns = fetch_absorbers if [:json] out.json(patterns.map { |p| { type: p[:type], value: p[:value], description: p[:description] } }) elsif patterns.empty? out.warn('No absorbers registered') else headers = %w[Type Pattern Description] rows = patterns.map do |p| [p[:type].to_s, p[:value], p[:description] || ''] end out.header('Registered Absorbers') out.table(headers, rows) end end |
#resolve(input_url) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/legion/cli/absorb_command.rb', line 53 def resolve(input_url) out = formatter result = fetch_resolve(input_url) if [:json] out.json(result) elsif result[:match] out.success("#{input_url} -> #{result[:absorber]}") else out.warn("No absorber registered for: #{input_url}") end end |
#url(input_url) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/legion/cli/absorb_command.rb', line 17 def url(input_url) out = formatter result = api_post('/api/absorbers/dispatch', url: input_url, context: { scope: [:scope] }) if [:json] out.json(result) elsif result[:success] out.success("Dispatched: #{input_url}") puts " absorber: #{result[:absorber]}" puts " job_id: #{result[:job_id]}" puts ' Processing in background. Check daemon logs for progress.' else out.warn("Failed: #{result[:error]}") end end |