sf_cli 1.0.0.beta3 → 1.0.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sf_cli/console/commands.rb +69 -10
- 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: a2cc80df9cc280f3fa0eda5ec72a2972ac5f036d3e9e407030668d984eab92c4
|
4
|
+
data.tar.gz: d8cd2eb983c18f81825d8bc83fa7cdee78b6c9c725970873d40ed42b52dd0ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06153a22706b868d9100f7f2f4f980c3847ee73d793f6649574ebaecf4c68f1bf21245217c432382669448a9f23bf6867772fe5853f1795dcafaa4f28a1428a5
|
7
|
+
data.tar.gz: 929bca993b4acf6c6a52d07ebe8adcbaa77dfa4b691ce72049e6a71d00e32a1bd79ee7c6211fe083d8d669959166bf3c82f68e7fa9f72eea7548165f7752e37a
|
@@ -8,27 +8,31 @@ 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
13
|
def use(_target_org)
|
24
14
|
target_org = _target_org.to_sym == :default ? nil : _target_org
|
25
15
|
org_info = sf.org.display target_org: target_org
|
16
|
+
raise "The connection is not ready. Please check by `sf org list`" unless org_info.connected?
|
17
|
+
|
26
18
|
conn = SfCli::Sf::Model::SfCommandConnection.new target_org: target_org, instance_url: org_info.instance_url
|
27
19
|
SfCli::Sf::Model.set_connection conn
|
20
|
+
|
21
|
+
available_models.each do |model|
|
22
|
+
Object.const_get(model).connection = conn
|
23
|
+
end
|
24
|
+
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
def available_models
|
29
|
+
@available_models ||= []
|
28
30
|
end
|
29
31
|
|
30
32
|
def generate(*object_types)
|
31
33
|
SfCli::Sf::Model.generate object_types
|
34
|
+
available_models.append(*object_types).flatten
|
35
|
+
object_types
|
32
36
|
end
|
33
37
|
|
34
38
|
def connection
|
@@ -45,8 +49,63 @@ module SfCli
|
|
45
49
|
sf.apex.run target_org: target_org, file: StringIO.new(apex_code)
|
46
50
|
end
|
47
51
|
|
52
|
+
def query(soql)
|
53
|
+
conf.inspect_mode = false
|
54
|
+
puts sf.data.query(soql, format: :human, target_org: target_org)
|
55
|
+
conf.inspect_mode = true
|
56
|
+
end
|
57
|
+
|
48
58
|
alias :gen :generate
|
49
59
|
alias :conn :connection
|
60
|
+
|
61
|
+
def help(command = nil)
|
62
|
+
conf.inspect_mode = false
|
63
|
+
puts <<~HELP
|
64
|
+
Available commands:
|
65
|
+
use --- set current org
|
66
|
+
gen --- generate Object model classes
|
67
|
+
query --- Query by SOQL with human readable format
|
68
|
+
apex --- run Apex code
|
69
|
+
conn --- show current connection setting
|
70
|
+
|
71
|
+
Syntax:
|
72
|
+
[use]
|
73
|
+
use target-org
|
74
|
+
|
75
|
+
parameters:
|
76
|
+
targat-org --- Username or alias of the org you are going to use.
|
77
|
+
|
78
|
+
[gen]
|
79
|
+
gen object-name, object-name, ...
|
80
|
+
generate object-name, object-name, ...
|
81
|
+
|
82
|
+
parameters:
|
83
|
+
object-name --- Comma separated Names. Symbol or String can be OK. At least 1 object name is required.
|
84
|
+
|
85
|
+
example:
|
86
|
+
gen :Account, :Contact, :User
|
87
|
+
|
88
|
+
[query]
|
89
|
+
query SOQL
|
90
|
+
|
91
|
+
parameters:
|
92
|
+
SOQL --- soql
|
93
|
+
|
94
|
+
[apex]
|
95
|
+
apex apex_code
|
96
|
+
|
97
|
+
parameters:
|
98
|
+
apex code --- Apex code you want to execute
|
99
|
+
|
100
|
+
example:
|
101
|
+
apex "System.debug('abc');"
|
102
|
+
|
103
|
+
[conn]
|
104
|
+
conn
|
105
|
+
connection
|
106
|
+
HELP
|
107
|
+
conf.inspect_mode = true
|
108
|
+
end
|
50
109
|
end
|
51
110
|
end
|
52
111
|
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
|