Any easy way to detect invoking of shortcuts, macros & aliases? #1369
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Off-hand, I don't think we built in any easy way to detect this as we intend them to be fully equivalent. We have always been completely agnostic when it comes to how end users choose to do logging and metrics. |
Beta Was this translation helpful? Give feedback.
-
|
I think you are on the right track, but you'll have to write a little bit of code in your hook. I'd suggest you utilize a precommand hook. The precommand hook will be called by
For step 1, you may find the following
In your hook you can check if |
Beta Was this translation helpful? Give feedback.

I think you are on the right track, but you'll have to write a little bit of code in your hook.
I'd suggest you utilize a precommand hook. The precommand hook will be called by
cmd2after the user input has been parsed (and the aliases expanded), but before the command is executed. In that hook, you'll have to write a bit of code, which will do two things:For step 1, you may find the following
cmd2instance variables to be useful:self.aliases- contains a dictionary of all aliases and what they expand toself.macros- contains a dictionary of all macros and what they exp…