sf_cli 1.0.0.beta3 → 1.0.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sf_cli/console/commands.rb +72 -12
- data/lib/sf_cli/sf/org/display.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0d747d19bb4e6c437c2314d83d2e11e138b8f3e241a43a59556fa7fad0829f6
|
4
|
+
data.tar.gz: 9474614d2da8a4bf6b7bc297d81d3221b90a13a65dba0727c1aa8067418bf37b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 951b09d44c48730ddb22fbe60b54b58179a4c5b34d42e2b374f5a68c291c1d5514dc735cd6a7585840cfaec1936d4b9187ab6846472d870142e502ddec1e8368
|
7
|
+
data.tar.gz: 4636eb0848036329af68fb63aec261e4eee191147d6c4327b4cc6ad4f4d516a8ae3c59239af0d969a0cbdc6ce6d8979e00984f90770167fe37e369bce2b3434c
|
@@ -8,27 +8,32 @@ module SfCli
|
|
8
8
|
module Console
|
9
9
|
#
|
10
10
|
# Developer Console commands
|
11
|
-
# @example
|
12
|
-
# $ bundle exec rake irb[your_target_org]
|
13
|
-
# irb(main):001> gen :Account, :Contact # generate Account and Contact class
|
14
|
-
# => [:Account, :Contact]
|
15
|
-
#
|
16
|
-
# irb(main):002> Account.describe.label
|
17
|
-
# => "Account"
|
18
|
-
#
|
19
|
-
# irb(main):003> apex "System.debug('abc');" # execute Apex code
|
20
|
-
# => returns the result
|
21
11
|
#
|
22
12
|
module Commands
|
23
|
-
def use(
|
24
|
-
target_org = _target_org.to_sym == :default ? nil : _target_org
|
13
|
+
def use(target_org)
|
25
14
|
org_info = sf.org.display target_org: target_org
|
15
|
+
#sf.org.login_web target_org: target_org, instance_url: org_info.instance_url unless org_info.connected?
|
16
|
+
|
26
17
|
conn = SfCli::Sf::Model::SfCommandConnection.new target_org: target_org, instance_url: org_info.instance_url
|
18
|
+
conn.open unless org_info.connected?
|
19
|
+
|
27
20
|
SfCli::Sf::Model.set_connection conn
|
21
|
+
|
22
|
+
available_models.each do |model|
|
23
|
+
Object.const_get(model).connection = conn
|
24
|
+
end
|
25
|
+
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def available_models
|
30
|
+
@available_models ||= []
|
28
31
|
end
|
29
32
|
|
30
33
|
def generate(*object_types)
|
31
34
|
SfCli::Sf::Model.generate object_types
|
35
|
+
available_models.append(*object_types).flatten
|
36
|
+
object_types
|
32
37
|
end
|
33
38
|
|
34
39
|
def connection
|
@@ -45,8 +50,63 @@ module SfCli
|
|
45
50
|
sf.apex.run target_org: target_org, file: StringIO.new(apex_code)
|
46
51
|
end
|
47
52
|
|
53
|
+
def query(soql)
|
54
|
+
conf.inspect_mode = false
|
55
|
+
puts sf.data.query(soql, format: :human, target_org: target_org)
|
56
|
+
conf.inspect_mode = true
|
57
|
+
end
|
58
|
+
|
48
59
|
alias :gen :generate
|
49
60
|
alias :conn :connection
|
61
|
+
|
62
|
+
def help(command = nil)
|
63
|
+
conf.inspect_mode = false
|
64
|
+
puts <<~HELP
|
65
|
+
Available commands:
|
66
|
+
use --- set current org. If you use your default org, this isn't needed.
|
67
|
+
gen --- generate Object model classes
|
68
|
+
query --- Query by SOQL with human readable format
|
69
|
+
apex --- run Apex code
|
70
|
+
conn --- show current connection setting
|
71
|
+
|
72
|
+
Syntax:
|
73
|
+
[use]
|
74
|
+
use target-org
|
75
|
+
|
76
|
+
parameters:
|
77
|
+
targat-org --- Username or alias of the org you are going to use.
|
78
|
+
|
79
|
+
[gen]
|
80
|
+
gen object-name, object-name, ...
|
81
|
+
generate object-name, object-name, ...
|
82
|
+
|
83
|
+
parameters:
|
84
|
+
object-name --- Comma separated Names. Symbol or String can be OK. At least 1 object name is required.
|
85
|
+
|
86
|
+
example:
|
87
|
+
gen :Account, :Contact, :User
|
88
|
+
|
89
|
+
[query]
|
90
|
+
query SOQL
|
91
|
+
|
92
|
+
parameters:
|
93
|
+
SOQL --- soql
|
94
|
+
|
95
|
+
[apex]
|
96
|
+
apex apex_code
|
97
|
+
|
98
|
+
parameters:
|
99
|
+
apex code --- Apex code you want to execute
|
100
|
+
|
101
|
+
example:
|
102
|
+
apex "System.debug('abc');"
|
103
|
+
|
104
|
+
[conn]
|
105
|
+
conn
|
106
|
+
connection
|
107
|
+
HELP
|
108
|
+
conf.inspect_mode = true
|
109
|
+
end
|
50
110
|
end
|
51
111
|
end
|
52
112
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module SfCli::Sf::Org
|
2
2
|
module Display
|
3
|
-
ConnectionInfo = Struct.new(:id, :access_token, :alias, :instance_url, :user_name, :api_version, :status)
|
3
|
+
ConnectionInfo = Struct.new(:id, :access_token, :alias, :instance_url, :user_name, :api_version, :status) do
|
4
|
+
def connected?
|
5
|
+
status == 'Connected'
|
6
|
+
end
|
7
|
+
end
|
4
8
|
|
5
9
|
#
|
6
10
|
# Returns the org's connection information
|