Pork To Sausage
The pork2Sausage.ini, accessible through Plugins > Pork to Sausage > Edit user commands, has a number of parameters for use in the the INI definitions, plus two special variables.
Parameters:
progPath: [Mandatory] The full path of the program to launch
This is the full path, including the name of the .exe
progCmd: [Mandatory] The whole command to call the program
This is the whole command; because the program path is given in the first Parameter, this one can use just the name of the command rather than the full path
workDir: [Mandatory] The path of working directory
This is needed for setting the “working directory” for the program – for example, if it needs to be able to find specific libraries relative to some “current directory”
progInput: [Optional] The full path name of the program input file. Pork to sausage plugin will write the selected text in a new created file with the given full path file name.
This is helpful if you don’t want to try to input the “selected text” (see variables, below) on the command line (or example, if the selected text is too long, or the external program doesn’t accept text input on the command line)
progOutput: [Optional] The full path name of the program output file. Pork to sausage plugin will replace selected text by the content of indicated file, which is supposed to be the output file of the program. If this parameter is absent, then Pork to sausage plugin will use the stdout of program to replace the selected text.
This is useful if the external program writes its output to a file, instead of STDOUT.
replaceSelection: [Optional] If its value is false, then the selected text will be untouched.
Set this to false if you don’t want the active selection in Notepad++ to be overwritten.
Variables
$(SELECTION): Your text selection.
The text will be encoded as UTF16-LE. Your external command must be able to handle the text in that encoding.
$(TIMESTAMP): the Timestamp which will be generated by Pork to Sausage at the start of the call. This varible used for naming the file created by Pork to sausage plugin (progInput) to ensure the unicity (uniqueness) of the created file.
Discussion
There are two primary input methods to your application.
You can send the selected text as an argument on the command line:progCmd=external.exe -inText "$(SELECTION)" ...
You can have Pork to Sausage create a temporary file containing the selection:progInput=%TEMP%\Pork2Sausage.$(TIMESTAMP).input
progCmd=external.exe -inputFile "%TEMP\Port2Sausage.$(TIMESTAMP).input"
Example
The default pork2sausage.ini gives a couple of examples of using just the command-line for the input text and the STDOUT of the command as the output text.
But to give an example which requires the selected-text be sent to a temporary file (progInput) and the output of the command to another file (progOutput), here is a version of the same action as used by the NppExec example from earlier:
[gpg-decrypt selection to self]
progPath=c:\usr\local\apps\gnupg\bin\gpg.exe
progCmd=gpg --output "C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).output" --decrypt "C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).asc"
progInput=C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).asc
progOutput=C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).output
workDir=C:\Users\XYZ\AppData\Local\Temp
The selected text will be written to the progInput file. Then progCmd will be run, which decrypts from the same file as progInput, and puts the result in the same file as progOutput. Then the plugin replaces the selected text with the contents of the progOutput file.