borysiasty / plugin_reloader

QGIS plugin: Reloads a chosen plugin in one click (only useful for Python Plugin Developers)
GNU General Public License v3.0
19 stars 16 forks source link

Option to append plugin' name to the extra commands typed #25

Closed jfbourdon closed 2 years ago

jfbourdon commented 3 years ago

Adds a checkbox to automatically append the plugin's name to the command. That way, I can let a script manage the origin and destination of files based (copying from dev directory to QGIS plugin directory):

image

Currently, I have to type in the extra commands text box something like python C:\dev\copyMyPlugin.py pluginUnderDevelopment. With his PR, I only need to type python C:\dev\copyMyPlugin.py and the pluginUnderDevelopment will be appended as the last argument automatically. That way, if I now switch my development to coolOtherPlugin, I don't have to change anything in my command and risk messing things up by misspelling the name for example.

Second thoughs It may not be the best approach. I was also thinking of simply adding a function to replace a specific string like %PluginName% by the plugin's name everywhere in the command string. That way, the name can be used at multiple places instead of just at the end. I would be replacing extra_commands += " " + currentPlugin() by extra_commands = extra_commands.replace('%PluginName%', currentPlugin()). I think it would have the added benefit to be more explicit.

jfbourdon commented 3 years ago

I convinced myself, a search and replace approach is just better in every way.

pluginName_v1

jfbourdon commented 2 years ago

The search and replace could also always be performed. That way, there isn't a new checkbox:

pluginName_v2

borysiasty commented 2 years ago

@jfbourdon I'm sorry, I missed all the notifications from this repo somehow! I like the third solution the most. The simpler, the better :) Could you please push it to the PR?

borysiasty commented 2 years ago

@jfbourdon Forget it, it's just two lines so I'm just doing it. I'm closing this MR, but the change will be done.

borysiasty commented 2 years ago

Here it is (with some extra love to the gui, eg. now the TextEdit availability is controlled by the checkbox): 8a83b74d6514b