Class: Turbot::Command::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/turbot/command/base.rb

Direct Known Subclasses

Auth, Bots, Help, Version

Constant Summary

Constants included from Helpers

Helpers::DEFAULT_HOST

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#api, #ask, #ask_for_password, #ask_for_password_on_windows, #delete_netrc_entry, #email_address_and_api_key, #error, #format_error, #host, #netrc_exists?, #netrc_path, #open_netrc, #save_netrc_entry, #styled_error, #turbot_api, #turbot_api_parameters

Constructor Details

#initialize(args = [], options = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
# File 'lib/turbot/command/base.rb', line 11

def initialize(args = [], options = {})
  @args = args
  @options = options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



8
9
10
# File 'lib/turbot/command/base.rb', line 8

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/turbot/command/base.rb', line 9

def options
  @options
end

Class Method Details

.namespaceObject



4
5
6
# File 'lib/turbot/command/base.rb', line 4

def self.namespace
  self.to_s.split('::').last.downcase
end

Instance Method Details

#botObject



16
17
18
19
20
21
22
23
24
# File 'lib/turbot/command/base.rb', line 16

def bot
  @bot ||= if options[:bot].is_a?(String)
    options[:bot]
  elsif ENV['TURBOT_BOT']
    ENV['TURBOT_BOT']
  elsif manifest = parse_manifest
    manifest['bot_id']
  end
end