Class: Chillfile::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/chillfile/cli.rb

Overview

CLI handles the command line interface for the ‘chillfile` binary. It is a `Thor` application.

Instance Method Summary collapse

Constructor Details

#initializeCLI

create a new instance with the args passed from the command line i.e. ARGV



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

def initialize(*)
  super
  
  cfg = {}
  cfg["path"]             = options[:path]
  cfg["couchdb_server"]   = options[:couchdb_server]
  cfg["couchdb_database"] = options[:couchdb_database]
  cfg["couchdb_type_key"] = options[:couchdb_type_key]
  
  Chillfile.boot!(cfg)
  
  if options[:version]
    say "chillfile v#{Chillfile::VERSION}", :red
    exit
  end
end

Instance Method Details

#dblistObject



64
65
66
# File 'lib/chillfile/cli.rb', line 64

def dblist
  say Chillfile.db_list
end

#fslistObject



59
60
61
# File 'lib/chillfile/cli.rb', line 59

def fslist
  say Chillfile.fs_list
end

#syncObject



49
50
51
52
53
54
55
56
# File 'lib/chillfile/cli.rb', line 49

def sync
  progressbar = lambda do |info, notifier|
    pbar = ::ProgressBar.new("#{info[:name]} (#{info[:size]})", info[:size])
    notifier.call(lambda{ pbar.inc })
    pbar.finish
  end
  Chillfile.sync!(progressbar)
end