Module: SfCli::Sf::Org::List

Defined in:
lib/sf_cli/sf/org/list.rb

Defined Under Namespace

Classes: OrgConfig

Instance Method Summary collapse

Instance Method Details

#listArray

Note:

this function returns org information including security sensitive things such as access token, username and so on.

List orgs you’ve created or authenticated to

Examples:

org_configs = sf.org.list        # returns a list of OrgConfig

org_configs.first.accesstoken         # returns the access token
org_configs.first.instance_url        # returns the org's url

org_configs.first.conncected?         # check the connection status
org_configs.first.devhub?             # check if the org is devhub or not
org_configs.first.scratch?            # check if the org is scratch or not
org_configs.first.default?            # check if the org is default or not
org_configs.first.default_devhub?     # check if the org is devhub default or not

Returns:

  • (Array)

    the org configulations

See Also:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sf_cli/sf/org/list.rb', line 51

def list
  flags = {
    # reserved for later option addition
  }
  json = exec(__method__, flags: flags, redirection: :null_stderr)

  others = json['result']['other'].map{|config| OrgConfig.new(**config)}
  sandboxes = json['result']['sandboxes'].map{|config| OrgConfig.new(**config)}
  non_scratch_orgs = json['result']['nonScratchOrgs'].map{|config| OrgConfig.new(**config)}
  devhubs = json['result']['devHubs'].map{|config| OrgConfig.new(**config)}
  scratch_orgs = json['result']['scratchOrgs'].map{|config| OrgConfig.new(**config)}
  
  (others + sandboxes + non_scratch_orgs + devhubs + scratch_orgs).uniq{|config| config.alias}
end