Class: TRMNLP::Commands::List

Inherits:
Base
  • Object
show all
Defined in:
lib/trmnlp/commands/list.rb

Defined Under Namespace

Classes: Options

Constant Summary collapse

PRIVATE_PLUGIN_ID =
37

Instance Method Summary collapse

Methods inherited from Base

#initialize, options_from, run

Constructor Details

This class inherits a constructor from TRMNLP::Commands::Base

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/trmnlp/commands/list.rb', line 13

def call
  authenticate!

  api = APIClient.new(config)
  response = api.get_plugin_settings
  plugins = (response || [])
            .select { |p| p['plugin_id'] == PRIVATE_PLUGIN_ID }
            .sort_by { |p| (p['name'] || '').downcase }

  if plugins.empty?
    reporter.info 'No plugins found.'
    return
  end

  reporter.info "Your plugins:\n\n"
  reporter.info '  ID        NAME'
  reporter.info "  #{'-' * 50}"

  plugins.each do |plugin|
    reporter.info format('  %-8s  %s', plugin['id'], plugin['name'])
  end

  reporter.info "\nTo clone a plugin:"
  reporter.info '    trmnlp clone [folder_name] [id]'
end