Class: Metaforce::CLI

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

Constant Summary collapse

CONFIG_FILE =
'.metaforce.yml'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.credential_optionsObject



17
18
19
20
21
22
23
# File 'lib/metaforce/cli.rb', line 17

def credential_options
  method_option :username, :aliases => '-u', :desc => 'Username.'
  method_option :password, :aliases => '-p', :desc => 'Password.'
  method_option :security_token, :aliases => '-t', :desc => 'Security Token.'
  method_option :environment, :aliases => '-e', :default => 'default', :desc => 'Environment to use from config file (if present).'
  method_option :host, :aliases => '-h', :desc => 'Salesforce host to connect to.'
end

.deploy_optionsObject



25
26
27
# File 'lib/metaforce/cli.rb', line 25

def deploy_options
  method_option :deploy_options, :aliases => '-o', :type => :hash, :default => { :run_all_tests => true }, :desc => 'Deploy Options'
end

.retrieve_optionsObject



29
30
31
# File 'lib/metaforce/cli.rb', line 29

def retrieve_options
  method_option :retrieve_options, :aliases => '-o', :type => :hash, :default => {}, :desc => 'Retrieve Options'
end

Instance Method Details

#deploy(path) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/metaforce/cli.rb', line 39

def deploy(path)
  say "Deploying: #{path} ", :cyan
  say "#{options[:deploy_options].inspect}"
  client.deploy(path, options[:deploy_options].symbolize_keys!)
    .on_complete { |job| report job.result, :deploy }
    .on_error(&error)
    .on_poll(&polling)
    .perform
end

#retrieve(manifest, path = nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/metaforce/cli.rb', line 54

def retrieve(manifest, path=nil)
  unless path
    path = manifest
    manifest = File.join(path, 'package.xml')
  end
  say "Retrieving: #{manifest} ", :cyan
  say "#{options[:retrieve_options].inspect}"
  client.retrieve_unpackaged(manifest, options[:retrieve_options].symbolize_keys!)
    .extract_to(path)
    .on_complete { |job| report(job.result, :retrieve) }
    .on_complete { |job| say "Extracted: #{path}", :green }
    .on_error(&error)
    .on_poll(&polling)
    .perform
end

#watch(path) ⇒ Object



75
76
77
78
79
# File 'lib/metaforce/cli.rb', line 75

def watch(path)
  say "Watching: #{path}"
  @watching = true
  Listen.to(path) { deploy path }
end