...
I started with Peter Chittum’s Apply the Salesforce CLI to Everyday Problems. Thankfully Peter is talking about Powershell and Bash these days. I went to the Github repo and all of a sudden was stuck. What is the ISE? Wh do I need to know about that? What is a profile? And everything past about half way in that video is a bit over my head - when he starts talking about “tail”, then I know he’s not talking to me. It’s like devs who just say “touch” the file. You know you are talking to a Mac dev and you know to just ignore and walk away and try to find someone that can speak your language.
So I think what he’s doing is trying to get you to have a default set of commands that open up each time you open VS Code. This is stored in a profile it seems. I could not work out Peter’s instructions though.
...
still works too!
Extending Functions
Now we can see in Peter’s example that functions can be a bit more interactive.
Code Block |
---|
Function dxopen ([string]$u) {
If ($u -ne '') {
sfdx force:org:open -u $u
} Else {
sfdx force:org:open
}
} |
so now we can see we can add parameters to functions. The $u is saying whatever is entered directly after dxopen then stick it after the command sfdx force:org:open -u
So I want to add another command like that to set default org.
sfdx force:config:set defaultusername=
Code Block |
---|
Function dxdefault ([string]$u) {
If ($u -ne '') {
sfdx force:config:set defaultusername=$u
} Else {
Return ''
}
} |
Reload VS Code
Type
Code Block |
---|
dxdefault yourOrgAlias |
The default org is now set.
Now you can use the window icon in the status bar to open that org.
Info |
---|
It’s pretty easy to just remember ctrl+shift+p start typing sfdx then arrow to the command you want to use, but having different options is good. |
That’s enough for now. At least we have some simple aliases.