abra-code / OMC

OnMyCommand
http://www.abracode.com/free/cmworkshop/on_my_command.html
MIT License
33 stars 5 forks source link

Simplify URL handler support #4

Closed abra-code closed 5 years ago

abra-code commented 5 years ago

OMC 3.2 has limited support for custom app URL handling You can add the custom URL in applet Info.plist:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>OMC Command</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>myapp</string>
        </array>
    </dict>
</array>

And then OMC engine executes a command with ID "omc.app.handle-url", passing the whole URL to the command as $OMC_OBJ_TEXT. It gives the flexibility ot add any URL handler to the applet. The problem is that the responsibility for parsing the whole percent escaped string is delegated to the command. The idea is to add a way to add a specialized protocol to execute chosen commands with given context just by opening a URL. This helps integrating an applet with other apps or web services. The design for URL query by example: myapp://exe?commandID=my.text.command.id&text=some%20text%20context myapp://exe?commandID=my.file.command.id&file=file1.txt&file=file2.txt

"myapp": unique protocol word which needs to be specified per applet in its Info.plist "exe": predefined query part which OMC recognizes as special case to execute a command "text" value becomes $OMC_OBJ_TEXT "file" value becomes $OMC_OBJ_PATH - one or more paths would be supported

abra-code commented 5 years ago

Fixed by commit: https://github.com/abra-code/OMC/commit/2aecc0a11f3c2e55b4e330f9b347e18eb46025ef