Is there a way to get the base directory of the project when creating a command? I know about the %p and %P interpolation shortcuts, but those only give me paths for the project file itself. I want the “project base directory” defined in the project properties. Is there some shortcut that will get me that or am I gonna have to write a macro? (Note: Because of some quirks with how our development environment is set up, I don’t really want to put the Komodo project files in the same directory as my source.)
There is no shortcut to get Komdo project base directory so you must write your own macro.
I was under the impression that %p
did this, but as you said it gives the directory that the project file is in. I’ll see about adding the project base directory as a variable.
You can get the base directory in a macro like this:
var partSvc = Cc["@activestate.com/koPartService;1"].getService(Ci.koIPartService);
var baseDir = partSvc.currentProject.liveDirectory;
Then you can run a command from the macro with this API: http://docs.activestate.com/komodo/8.5/komodo-js-api.html#ko.run
Thanks guys! I was hoping I’d missed something in the docs, but apparently not.
At any rate, with the pointer to the docs I was able to bang out a macro for it without too much trouble. It would still be nice to have that as a variable when creating commands, though. The documentation for ko.run is a bit…sparse. It was fairly straight forward once I looked up the source for ko.run.runCommand(), but that really shouldn’t be necessary.
But anyway, problem solved. Thanks again!
Yep we’re aware, a complete documentation overhaul is in the works as well as an easier to use SDK.
Thanks for the comments - Komodo 9 will include a new interpolation shortcut for the project base directory.