feat(cli): allow specifying the default protocol in config files #1713
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.
What is the current behavior?
Previously, config files couldn't specify the default protocol.
What is the new behavior?
Config files can now specify the default protocol.
The init command has also been updated to prompt for the protocol, and it also recommends a different default port based on the selected protocol.
Does this PR introduce a breaking change?
Other information
Although I updated the init command to recommend / use a different default port based on the protocol, I didn't update the default port to be based on protocol anywhere else in the app, since I thought that might be too much of a breaking change.
Similarly, if you manually create a config file with a protocol other than
mqtt
but don't specify a port, it will use the default port of 1883 instead of what was recommended by the init command. We could maybe determine the default port based on the protocol in this case without it being a breaking change (since the protocol config property is new), but I worry whether that will lead to unexpected inconsistencies compared to specifying a protocol with command line flags.Because of this, I'm not sure whether it actually makes sense for the init script to suggest a different port based on the selected protocol, but I figure it's worth at least discussing.
(And then as an aside, there might be other defaults that should be overridable using a config file, such as websocket path, ca cert, alpn, etc. I didn't have a need for any of those properties in my configuration though, so I only added the protocol for now. Alternatively, it might make sense to use a URI for some of these parameters. That would be a more involved change though.)