sf_cli 1.0.0.beta2 → 1.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59be3ef9caa559c104e1aeeee112637716428a2eaf573f04aecedef5aab7c58d
4
- data.tar.gz: baf6694c9d1b3ab897b381ba053201e839b76bcba97efa69a440270167c26460
3
+ metadata.gz: a2cc80df9cc280f3fa0eda5ec72a2972ac5f036d3e9e407030668d984eab92c4
4
+ data.tar.gz: d8cd2eb983c18f81825d8bc83fa7cdee78b6c9c725970873d40ed42b52dd0ce4
5
5
  SHA512:
6
- metadata.gz: c21e490286e01927720ec9582b99e8d26ac59f8e876a52be1c07adbf100647b802d1abfdbba55cdf1869c2ed21a83940087531bdd99862ac4c2d1c2c397a7fbe
7
- data.tar.gz: 770d34b4a20fbf4af0c0525e7ea0af27e9834dea6b4a15251b7b3f87f4744ed789d8d021e79d877e789ed7558bf597df8e4b0e06829ff6f99cbab1d4ff6585dc
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
@@ -2,4 +2,4 @@ require 'sf_cli/console/commands'
2
2
 
3
3
  include SfCli::Console::Commands
4
4
 
5
- use ARGV[0]
5
+ use ARGV[0] if ARGV[0]
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sf_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takanobu Maekawa
@@ -14,13 +14,13 @@ description: A class library for introducing Salesforce CLI to Ruby scripting. C
14
14
  only sf command is the target of development.
15
15
  email:
16
16
  executables:
17
- - sfdc
17
+ - sf_cli
18
18
  extensions: []
19
19
  extra_rdoc_files:
20
20
  - README.rdoc
21
21
  files:
22
22
  - README.rdoc
23
- - bin/sfdc
23
+ - bin/sf_cli
24
24
  - lib/sf_cli.rb
25
25
  - lib/sf_cli/console.rb
26
26
  - lib/sf_cli/console/commands.rb
File without changes