Dynamic callback for registered command


Hey guys,

I stumbled upon a problem while expanding my snippet-injector package.
I want to allow exporting options for data, referenced by the main menu as single menu items e.g. “CSV” then “TXT” and so on. But I don’t want to create a single command for each of them since it makes my code more than untidy.
I searched a bit throughout the web but didn’t find any appropriate solution so I ask it here:

Is it possible to retrieve the clicked menu item within the callback registered for the dispatched command?
I know that the callback recieves the DOM Element as this context, but since the command is registered on the atom-workspace element I retrieve it as context but that doesn’t makes it possible to get the menu items name.
The event argument of the callback doesn’t help either cause it brings up a hidden input field without any further information as target.

Or if this is not possible at all, can I define a callback with a static argument? I mean that the invoked callback would not be like this.exportToCSV() but this.export('csv') called every time with the given string as argument?

Thanks in advance for your help :slightly_smiling_face: