Class: Winnie::Commands::Base
- Inherits:
-
Object
- Object
- Winnie::Commands::Base
- Includes:
- Helpers
- Defined in:
- lib/winnie/commands/base.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#winnie ⇒ Object
readonly
Returns the value of attribute winnie.
Instance Method Summary collapse
- #code_name ⇒ Object
- #config_path ⇒ Object
- #extract_options(args) ⇒ Object
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
Methods included from Helpers
#ask, #confirm, #display, #display_columns, #error, #line
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/winnie/commands/base.rb', line 8 def initialize(*args) @args = args.flatten (@args) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/winnie/commands/base.rb', line 4 def api_key @api_key end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/winnie/commands/base.rb', line 4 def args @args end |
#winnie ⇒ Object (readonly)
Returns the value of attribute winnie.
4 5 6 |
# File 'lib/winnie/commands/base.rb', line 4 def winnie @winnie end |
Instance Method Details
#code_name ⇒ Object
27 28 29 |
# File 'lib/winnie/commands/base.rb', line 27 def code_name @code_name || raise(ApplicationNotSpecyfiedException.new) end |
#config_path ⇒ Object
36 37 38 |
# File 'lib/winnie/commands/base.rb', line 36 def config_path File.('~/.winnie') end |
#extract_options(args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/winnie/commands/base.rb', line 13 def (args) return if args.empty? OptionParser.new do |opts| opts.on("-a", "--app [CODE-NAME]", :text, "Run for given application") do |a| @code_name = a end opts.on("-k", "--api-key [API-KEY]", :text, "Authorize command for given api key") do |k| @api_key = k end end.parse!(@args) end |