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

#list(raw_output: false) ⇒ Array

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

Parameters:

  • raw_output (Boolian) (defaults to: false)

    return the original command’s output.

Returns:

  • (Array)

    the org configulations

See Also:



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

def list(raw_output: false)
  flags = {
    # reserved for later option addition
  }
  output = org_exec(__method__, flags: flags, redirection: :null_stderr, raw_output: raw_output)

  return output if raw_output

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