databasedotcom_console 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/dbdc CHANGED
@@ -3,36 +3,64 @@
3
3
  require 'databasedotcom_console'
4
4
  require 'irb'
5
5
  require 'io/console'
6
+ require 'optparse'
6
7
 
7
8
  ### RANDOM UTIL METHOD
8
- def get_creds
9
+ def get_creds(opts={})
9
10
  creds = {}
10
- print "HOST (test.salesforce.com, login.salesforce.com, etc): "
11
- creds[:host] = gets.strip
12
- print "USERNAME: "
13
- creds[:un] = gets.strip
14
- print "PASSWORD (and security token if necessary): "
15
- creds[:pw] = STDIN.noecho(&:gets)
11
+ if opts[:host]
12
+ creds[:host] = opts[:host]
13
+ else
14
+ print "HOST (test.salesforce.com, login.salesforce.com, etc): "
15
+ creds[:host] = gets.strip
16
+ end
17
+ if opts[:un]
18
+ creds[:un] = opts[:un]
19
+ else
20
+ print "USERNAME: "
21
+ creds[:un] = gets.strip
22
+ end
23
+ if opts[:pw]
24
+ creds[:pw] = opts[:pw]
25
+ else
26
+ print "PASSWORD (and security token if necessary): "
27
+ creds[:pw] = STDIN.noecho(&:gets)
28
+ end
16
29
  creds
17
30
  end
18
31
 
32
+ options = {}
33
+ parser = OptionParser.new do |opts|
34
+ opts.banner = "Usage: dbdc [options]"
35
+ opts.on("-h","--host HOST","enter the host (login.salesforce.com or test.salesforce.com") do |arg|
36
+ options[:host] = arg
37
+ end
38
+ opts.on("-u","--username USERNAME","your username") do |arg|
39
+ options[:un] = arg
40
+ end
41
+ opts.on("-p","--password PASSWORD","your password") do |arg|
42
+ options[:pw] = arg
43
+ end
44
+ end
45
+ parser.parse!
46
+
19
47
  if ARGV[0] == "exec"
20
48
  path = ARGV[1]
21
49
  ARGV.clear
22
- creds = get_creds
50
+ creds = get_creds(options)
23
51
  @dbdc = DatabasedotcomConsole.new_client(creds[:host], creds[:un], creds[:pw])
24
52
  DatabasedotcomConsole::ScriptRunner.new(path, @dbdc)
25
53
  else
26
54
  begin
27
- creds = get_creds
55
+ creds = get_creds(options)
28
56
  @dbdc = DatabasedotcomConsole.new_client(creds[:host], creds[:un], creds[:pw])
29
57
 
30
58
  def dbdc
31
59
  @dbdc
32
60
  end
33
61
 
34
- puts "\n\nWelcome to the Databasedotcom Ruby Console. \nYou you can access your databasedotcom client via the variable @dbdc"
35
- puts "\nExamples: \n"
62
+ puts "\n\nWelcome to the Databasedotcom Ruby Console. \nYou you can access your databasedotcom client via the variable: @dbdc"
63
+ puts "\nExamples:\n"
36
64
  puts "@dbdc.list_sobjects"
37
65
  puts "@dbdc.materialze \'Account\'"
38
66
  puts "john = Account.find_by_LastName \'Yamaguchi\'"
@@ -1,3 +1,3 @@
1
1
  module DatabasedotcomConsole
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: databasedotcom_console
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: