Class: Appetize::Commands::Update

Inherits:
Appetize::Command show all
Defined in:
lib/appetize/commands/update.rb

Instance Method Summary collapse

Methods inherited from Appetize::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(path, public_key, token, api_host, options) ⇒ Update

Returns a new instance of Update.


9
10
11
12
13
14
# File 'lib/appetize/commands/update.rb', line 9

def initialize(path, public_key, token, api_host, options)
  @api        = Appetize::API.new(token, api_host)
  @path       = path
  @public_key = public_key
  @options    = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/appetize/commands/update.rb', line 16

def execute(input: $stdin, output: $stdout)
  response = @api.update(@path, @public_key)

  raise "Update failed: #{response.code}" unless response.code == 200

  output.puts response.body
end