Class: ThreeScaleToolbox::Commands::AccountCommand::Find::FindSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command
Defined in:
lib/3scale_toolbox/commands/account_command/find_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/3scale_toolbox/commands/account_command/find_command.rb', line 11

def self.command
  Cri::Command.define do
    name        'find'
    usage       'find [opts] <remote> <text>'
    summary     'find account'
    description 'Find account by email, provider key or service token'

    option      :a, :'print-all', 'Print all the account info', argument: :forbidden
    param       :remote
    param       :text

    runner FindSubcommand
  end
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/3scale_toolbox/commands/account_command/find_command.rb', line 26

def run
  client = threescale_client(arguments[:remote])
   = ThreeScaleToolbox::Entities::Account.find_by_text(arguments[:text], client)
  if .nil?
    puts 'Account not found'
    return
  end

  .verbose = options[:'print-all']
  puts 
end