Retrieving/passing command-line options from a plugin
Hi,
I'm writing a command-line plugin to perform a custom export of some metadata.
Is there a way to access from the plugin the command line options, whether passed by string (e.g. "C:\Program Files\MuseScore 3\bin\MuseScore3.exe" -p mcveCmdLine.qml -o "xyz "path\to\some\file.mscz") or by Json file ?
Actually I'd like to pass to the plugin a filename where to do that export or a config file telling where to do it.
I could either retrieve the "-o" command or retrieve the "out:" param from the json.
Or use a specific tag.
Anyone with experience with this ?
Cheers
Comments
These are, to my knowledge, not shared with the plugin that is being run.
You can use
Qt.application.arguments
in the plugin to get a list of all command-line arguments passed to the application (see QML docs). Given that, you can search through that list for the argument your plugin needs.From my experience there is a different issue here: MuseScore also interprets command-line arguments with its own logic — for example, the
-o
argument will make MuseScore attempt to save something into that file. Passing a completely custom option doesn't work as it is not permitted by the MuseScore's command line parser. The workaround I have found is using the--highlight-config
option which doesn't affect MuseScore's behavior in the non-GUI mode but still makes its command line parser satisfied. So for invoking my plugins which need to take command-line arguments I use something like the following:In reply to You can use Qt.application… by dmitrio95
I'm testing this right away !! Thanks.
In reply to You can use Qt.application… by dmitrio95
Tested with success. Thanks.
Although, the behaviour on Windows doesn't seems to be the same yours (Linux ?).
Non recognized parameters such as your
--highlight-config 'my plugin args'
are throwing an errors.While recognized parameters such as a
-o "path/to/some/file/"
are passed to the plugin.I combined this with a conversion extension not recognized by Musescore (such as ".tmp") so that MuseScore doesn't try to perform a conversion itself.
In short:
In reply to Tested with success. Thanks… by parkingb
Using <qml>...</qml> even with syntax higlighting ;-)
In reply to Tested with success. Thanks… by parkingb
Try
--score-highlight-config
instead. See https://musescore.org/en/handbook/3/command-line-options for a list of "accepted" arguments by MuseScore to see which one you can abuse for this purpose.In reply to Try --score-highlight-config… by jeetee
Probably some spelling error, because it is now working with
--highlight-config
. Thanks.[OFF TOPIC]
The documentation is not super-clear (for the "--xxx" options) which of these options are taking parameters. E.g. for the "highlight-config" there is no mention of this taking a string as parameters.
In reply to You can use Qt.application… by dmitrio95
Sneaky wizard honors to you, dmitrio95 ;-)
Is it only me, or even a basic hello world plugin don't run on MuseScore 4.2.1?
Something with
onRun: {
console.log('running function')
}
when invoked with
mscore test.mscz --plugin test.qml --debug -o test.pdf
generate a warning 'Qt | No such plugin for spec "test.qml"'
In reply to Is it only me, or even a… by opinsky
Try with the full path of the plugin
In reply to Try with the full path of… by Jojo-Schmitz
Same error (on a Mac with Sonoma). Tested the full path and the './test.qml' :-(
In reply to Same error (on a Mac with… by opinsky
full part, I meant the absolute path
In reply to full part, I meant the… by Jojo-Schmitz
Yes, i've tried the full absolute path /Users/opinsky/Documents/MuseScore4/Plugins/test.qml