Class: BookableCloud::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bookable_cloud/cli.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



14
15
16
# File 'lib/bookable_cloud/cli.rb', line 14

def check
  check_configuration!
end

#fetchObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bookable_cloud/cli.rb', line 19

def fetch
  check_configuration!

  assets = api_client.list_assets

  assets.each do |key|
    fetch_asset(key)
    log "Fetched: #{key}"
  end
  # say("Done.", :green) unless options['quiet']
end

#watchObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bookable_cloud/cli.rb', line 32

def watch
  check_configuration!

  log "Watching directory: #{Dir.pwd}"
  Listen.to(Dir.pwd) do |modified, added, removed|
    modified.each do |filename|
      filename = filename.gsub("#{Dir.pwd}/", '')

      next if File.directory?(filename)

      upload_asset filename
    end
  end.start
  sleep
end