= Salesforce CLI library for Ruby https://badge.fury.io/rb/sf_cli.png
This is a class library for introducing {Salesforce CLI}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_top.htm] to Ruby scripting.
It is designed to be similar usability to the original command.
Currently only sf command is the target of development.
== prerequisite
Salesforce CLI must be installed.
As of as of September in 2024, ver.2.56.7 is the development target.
== install Rubygem:: the simplest way: $ gem install sf_cli Bundler:: in Gemfile: gem 'sf_cli' then, $ bundle install == Documents Class Library Reference:: {Online document}[https://www.rubydoc.info/gems/sf_cli/0.0.7] at rubygems.org
Or,
Generate locally:
$ git clone https://github.com/tmkw/sf_cli.git
$ cd sf_cli
$ bundle install
$ bundle exec rake rdoc
*As* *of* *now*, *this* *is* *better* *to* *know* *what* *it* *is* *exactly*.
Salesforce CLI and Sf command::
== Short Examples require 'sf_cli'
sf.org.login_web
sf.sobject.describe :Account
sf.data.get_record :Account, record_id: 'xxxxxxx' sf.data.get_record :Account, where: {Name: 'Jonny B.Good', Country: 'USA'}
sf.data.query "SELECT Id, Name FROM Account LIMIT 1" # => [{Id: "abc", Name: "account name"}]
sf.data.create_record :TheCustomObject__c, values: {Name: "John Smith", Age: 33}
sf.data.update_record :Account, record_id: 'xxxxxxx', values: {Name: 'New Account Name'} sf.data.update_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}, values: {Phone: 'xxxxx', bar: 2000}
sf.data.delete_record :Hogec, record_id: 'xxxxxxx' sf.data.delete_record :Hogec, where: {Name: 'Jonny B.Good', Country: 'USA'}
sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv', timeout: 5 # waiting for 5 minutes at maximum
sf.apex.run file: 'path/to/file' sf.apex.run file: StringIO.new("System.debug('Hello World')") == \Object Model Support As of now, there is experimental support for object model in Salesforce. === Short examples ===== With sf command: rows = sf.data.query "SELECT Id, Name FROM Contact WHERE Name = 'Akin Kristen'", model_class: Contact rows.first # <Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen"> rows.first.Name # Akin Kristen ===== Doing the same thing with model independently contact = Contact.select(:Id, :Name).where(Name: 'Akin Kristen').take contact.Name # Akin Kristen