Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
README.md
is updated with the changes (if needed)Version
Requires a MINOR version update
Context
We want to better understand how our users are using the CLI so we will be collecting what commands are executed and which flags are used.
Implementation
I have extended the existing logger with a new event.
At the moment the run command was initialising the tracker and it was the only user of it. This was not good because we need to log the command info much earlier. So I moved the tracker initialisation where the CLI execution starts. With this there was a new problem with how to share this tracker with the run command.
We are using the urfave cli package to parse and execute the tasks. This package has a
Context
(not the same as the GoContext
one) struct which will trickle down to the commands. But you can only add strings to it. So the simplest solution seemed to put the tracker into a global variable and inject that into the execution flow.