FIX #2719: enforce name argument of migration generate command #6690
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.
User error sometimes leads to running the migration generate command with invalid parameters. If the
-n
argument for the name of the migration class is completely missing, it returns a useful error to the user:However, if the user includes the
-n
argument but forgets to pass in a value for that option, currently theyargs
library is interpreting that as a positional argument, with a value oftrue
(https://github.com/yargs/yargs/blob/master/docs/advanced.md#positional-arguments). This then results in the aforementionedTypeError: str.replace is not a function
error whenname
is passed into thecamelCase
method.The goal of this PR is to improve the messaging returned to the user in this case; hopefully making it more obvious how to resolve.
Previous work was done in this area to return a message if the
name
argument is empty: e68538abut it doesn't work here because of the argument being coerced into a boolean value.
This PR adds the
type: "string"
to thename
argument options passed toyarg
. This tells theyarg
library to treat this argument as a string at all times, and a missing value will be interpreted as an empty string, rather than a positional argument. With this PR we get the following:Note to maintainers: I am happy to add tests if wanted; but I wasn't able to find any existing tests for what's returned by the various CLI commands; and this was a fairly small change.
Closes (or at least, resolves the confusion brought up by): #2719, #4798, #4805