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.
This PR stubs out a new
cli
package forgoose
. There are no changes with the existinggoose
CLI code and everything is gated behind a feature flagGOOSE_CLI=1
.Some highlights
Help for every command (
--help
and-h
)Will output nicely formatted help (currently only supports the
goose status
command, but others will quickly follow)JSON support (
--json
)It supports
--json
out-of-the-box, e.g.,Returns output that can be used programmatically, recently brought up by @witsch in #420 (comment), but requested for a long time #225, #350, etc.
Driver and dialect automatically inferred from dbstring
We can infer the dialect based on the supplied DSN (called
--dbstring
).Previously goose had the caller supply a driver name AND a dbstring, but the former is not necessary and we already know ahead of time which databases we support so we can used a handy package to map that connection string to a dialect, https://github.com/xo/dburl#database-schemes-aliases-and-drivers.
goose [OPTIONS] DRIVER DBSTRING COMMAND
where the DRIVER AND DBSTRING are automatically converted to--dbstring
?Use a lightweight framework for composing CLI
...
Expose the CLI code to users
These 2 functions will be available to users so they can integrate goose into their own applications and get the same CLI experience. Should resolve a few requests like this one #646