Skip to content

Commit fd0b63e

Browse files
committed
expr and statement
1 parent e0f978a commit fd0b63e

3 files changed

Lines changed: 63 additions & 13 deletions

File tree

.bashrc

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,11 @@ lbl() {
12261226
}
12271227

12281228
# Execute an apex statement against an environment
1229-
stmt() {
1229+
exp() {
12301230
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
1231-
echo "Execute a statement, and print the output. Takes the apex statement you pass in and wraps it in a System.debug() call."
1231+
echo "Execute an expression, and print the output. Takes the apex statement you pass in and wraps it in a System.debug() call."
12321232
echo "Pass quiet or q as the last paremeter to supress notification messages"
1233-
echo "Usage: stmt [ORG_ID] [STATEMENT_TO_EVALUATE] ['quiet' | 'q']"
1233+
echo "Usage: exp [ORG_ID] [STATEMENT_TO_EVALUATE] ['quiet' | 'q']"
12341234
return 1
12351235
fi
12361236

@@ -1258,3 +1258,53 @@ stmt() {
12581258
sed '$d' | # remove the last line, which is the first non-debug line
12591259
sed 's/.*\|//' # find everything after the last pipe, which will be the debugged output
12601260
}
1261+
1262+
stmt() {
1263+
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
1264+
echo "Execute a statement or list of statements"
1265+
echo "Pass quiet or q as the last paremeter to supress notification messages"
1266+
echo "Usage: stmt [ORG_ID] [STATEMENT_TO_EVALUATE] ['quiet' | 'q']"
1267+
return 1
1268+
fi
1269+
1270+
local apexCommand
1271+
apexCommand=${2}
1272+
if [ "$3" != "quiet" ] && [ "$3" != "q" ]; then
1273+
>&2 echo "${COLOR_BLUE}${BOLD}Executing:${COLOR_RESET}"
1274+
>&2 echo "${COLOR_BLUE}${apexCommand}${COLOR_RESET}"
1275+
>&2 echo
1276+
fi
1277+
1278+
# Example apex output, to see what we're grepping for. Logs for the
1279+
# multline command System.debug('a\nb'):
1280+
# 11:38:56.11 (11521203)|EXECUTION_STARTED
1281+
# 11:38:56.11 (11525424)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
1282+
# 11:38:56.11 (11944606)|USER_DEBUG|[1]|DEBUG|a
1283+
# b
1284+
# 11:38:56.11 (11980694)|CUMULATIVE_LIMIT_USAGE
1285+
# 11:38:56.11 (11980694)|LIMIT_USAGE_FOR_NS|(default)|
1286+
# We need to find from the start of USER_DEBUG to the next non-debug line.
1287+
# Notice "b" is put on a line by itself, making it tricky to include in output
1288+
1289+
sfdx force:apex:execute -u "${1}" -f /dev/stdin<<<"$apexCommand" # Execute the statement inside a system.debug(). execute expects a file, so use <<< trick to make it seem like a file
1290+
}
1291+
1292+
alias lsorg='open https://grhc.lightning.force.com/lightning/setup/DataManagementCreateTestInstance/home'
1293+
function orgid() {
1294+
exp "$1" 'UserInfo.getOrganizationId()'
1295+
}
1296+
1297+
# Some normal junk
1298+
fzf_opts="--multi --layout=reverse --border"
1299+
1300+
# Preview files to the right, in bat for colorizing
1301+
fzf_opts="${fzf_opts} --preview 'bat --style=numbers --color=always {}'"
1302+
1303+
# Doesn't work?
1304+
# Make file list use ripgrep, which auto-ignores git and node_modules by default
1305+
# export FZF_DEFAULT_COMMAND='rg --files'
1306+
1307+
export FZF_DEFAULT_OPTS="$fzf_opts"
1308+
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
1309+
1310+
alias ga="git ls-files -m --exclude-standard | fzf --print0 -m | xargs -0 -t -o git add"

code/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"**/tmp": true
1313
},
1414
"git.autofetch": false,
15-
"editor.minimap.enabled": true,
15+
"editor.minimap.enabled": false,
1616
// NOOOOOOOO
1717
"workbench.editor.enablePreview": true,
1818
"workbench.editor.enablePreviewFromQuickOpen": false,

code/snippets/ecmascript.code-snippets

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"Console Log Parse": {
2727
"scope": "javascript,typescript",
28-
"prefix": "cjj",
28+
"prefix": "cj'",
2929
"body": [
3030
"console.log('$1', JSON.parse(JSON.stringify($1)))",
3131
],
@@ -63,12 +63,12 @@
6363
],
6464
"description": "Console log value name and value"
6565
},
66-
"Console Log Emoji 🔥": {
67-
"scope": "javascript,typescript",
68-
"prefix": "cc",
69-
"body": [
70-
"console.log('${1|🔥,❌,🚽,🌿,💙|}$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1')"
71-
],
72-
"description": "Make console output noticable"
73-
}
66+
"Console Log Emoji 🔥": {
67+
"scope": "javascript,typescript",
68+
"prefix": "cc",
69+
"body": [
70+
"console.log('${1|🔥,❌,🚽,🌿,💙|}$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1')"
71+
],
72+
"description": "Make console output noticable"
73+
}
7474
}

0 commit comments

Comments
 (0)