Module: SfCli::Console::Commands
- Defined in:
- lib/sf_cli/console/commands.rb
Overview
Developer Console commands
Instance Method Summary collapse
- #apex(apex_code = nil) ⇒ Object
- #available_models ⇒ Object
- #connection ⇒ Object (also: #conn)
- #generate(*object_types) ⇒ Object (also: #gen)
- #help ⇒ Object
- #orgs ⇒ Object
- #query(soql) ⇒ Object
- #target_org ⇒ Object
- #use(target_org) ⇒ Object
Instance Method Details
#apex(apex_code = nil) ⇒ Object
45 46 47 48 49 |
# File 'lib/sf_cli/console/commands.rb', line 45 def apex(apex_code = nil) return sf.apex.run target_org: target_org if apex_code.nil? sf.apex.run target_org: target_org, file: StringIO.new(apex_code) end |
#available_models ⇒ Object
27 28 29 |
# File 'lib/sf_cli/console/commands.rb', line 27 def available_models @available_models ||= [] end |
#connection ⇒ Object Also known as: conn
37 38 39 |
# File 'lib/sf_cli/console/commands.rb', line 37 def connection SfCli::Sf::Model.connection end |
#generate(*object_types) ⇒ Object Also known as: gen
31 32 33 34 35 |
# File 'lib/sf_cli/console/commands.rb', line 31 def generate(*object_types) SfCli::Sf::Model.generate object_types available_models.append(*object_types).flatten object_types end |
#help ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/sf_cli/console/commands.rb', line 66 def help conf.inspect_mode = false puts " Available commands:\n use --- set current org.\n gen --- generate Object model classes\n query --- Query by SOQL with human readable format\n apex --- run Apex code\n conn --- show current connection setting\n orgs --- show the list of org\n\n Syntax:\n [use]\n use target-org\n\n parameters:\n targat-org --- Username or alias of the org you are going to use. If you are not sure about them, check by `sf org list`.\n\n example:\n use :your_org_alias\n\n [gen]\n gen object-name, object-name, ...\n generate object-name, object-name, ...\n\n parameters:\n object-name --- Comma separated Names. Symbol or String can be OK. At least 1 object name is required.\n\n example:\n gen :Account, :Contact, :User\n\n [query]\n query SOQL\n\n parameters:\n SOQL --- soql.You must quote it like \"SELECT ....\"\n\n example:\n query \"SELECT Id, Name FROM Account LIMIT 3\"\n\n [apex]\n apex apex_code\n\n parameters:\n apex code --- Apex code you want to execute.You must quote the code.\n\n example:\n apex \"System.debug('abc');\"\n\n [conn]\n conn\n connection\n\n [orgs]\n orgs\n HELP\n conf.inspect_mode = true\nend\n" |
#orgs ⇒ Object
57 58 59 60 61 |
# File 'lib/sf_cli/console/commands.rb', line 57 def orgs conf.inspect_mode = false system 'sf org list' conf.inspect_mode = true end |
#query(soql) ⇒ Object
51 52 53 54 55 |
# File 'lib/sf_cli/console/commands.rb', line 51 def query(soql) conf.inspect_mode = false puts sf.data.query(soql, format: :human, target_org: target_org) conf.inspect_mode = true end |
#target_org ⇒ Object
41 42 43 |
# File 'lib/sf_cli/console/commands.rb', line 41 def target_org connection.target_org end |
#use(target_org) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sf_cli/console/commands.rb', line 13 def use(target_org) org_info = sf.org.display target_org: target_org conn = SfCli::Sf::Model::SfCommandConnection.new target_org: target_org, instance_url: org_info.instance_url conn.open unless org_info.connected? SfCli::Sf::Model.set_connection conn available_models.each do |model| Object.const_get(model).connection = conn end true end |