diff --git a/SFDX.py b/SFDX.py index 341e959..4491921 100644 --- a/SFDX.py +++ b/SFDX.py @@ -11,7 +11,7 @@ async def main(connection): @iterm2.RPC async def displayExpirationDate(session_id): await component.async_open_popover(session_id, "

Retrieving org expiration date... (wait)

", iterm2.Size(300, 30)) - + from subprocess import Popen, PIPE import json p = Popen(['sfdx force:org:display --targetusername=' + aliasOrUsername + ' --json'], stdin = PIPE, stdout = PIPE, stderr = PIPE, universal_newlines = True, shell = True) @@ -30,18 +30,18 @@ async def displayExpirationDate(session_id): expiration += '(expired)' elif stdout: expiration += 'Never - org is a sandbox.' - + await component.async_open_popover(session_id, "

The scratch org expires on: " + expiration + '

', iterm2.Size(350, 30)) - + knobs = [iterm2.CheckboxKnob("Enable expiration date", False, "showExpirationDate")] component = iterm2.StatusBarComponent(short_description = "SFDX Status", detailed_description = "Provides status info for SFDX project folders", knobs = knobs, exemplar = u"\u2601 SFDC-1234 user@salesforce.com", update_cadence = None, identifier = "com.msk.sfdx") - + @iterm2.StatusBarRPC async def coro(knobs, path = iterm2.Reference("path"), cwd = iterm2.Reference("user.currentDir?")): import os import json from pathlib import Path - + currentDir = path if 'force-app' in currentDir: # User is in subdirectory currentDir = currentDir.split('force-app')[0] # Get root directory of project folder @@ -52,18 +52,18 @@ async def coro(knobs, path = iterm2.Reference("path"), cwd = iterm2.Reference("u config = json.load(configFile) global aliasOrUsername aliasOrUsername = config['defaultusername'] - + # Retrieve username for alias with open(os.environ['HOME'] + '/.sfdx/alias.json') as aliasFile: alias = json.load(aliasFile) - + if 'defaultusername' in config and 'orgs' in alias: return u'\u2601 ' + config['defaultusername'] + u' \u2022 ' + alias['orgs'][config['defaultusername']] else: return u'\u2601' # Some error occurred, e.g. file not found or wrong content else: return u'\u2601' # No SFDX directory - + await component.async_register(connection, coro, timeout = 15.0, onclick = displayExpirationDate)