add --old-format flag to dolt init

This commit is contained in:
Andy Arthur
2022-09-29 15:56:24 -07:00
parent 7f1a492655
commit 3d74a7255a
2 changed files with 12 additions and 4 deletions

View File

@@ -100,7 +100,6 @@ const (
BranchParam = "branch"
TrackFlag = "track"
AmendFlag = "amend"
NewFormatFlag = "new-format"
CommitFlag = "commit"
NoCommitFlag = "no-commit"
NoEditFlag = "no-edit"

View File

@@ -32,6 +32,8 @@ const (
emailParamName = "email"
usernameParamName = "name"
initBranchParamName = "initial-branch"
newFormatFlag = "new-format"
oldFormatFlag = "old-format"
)
var initDocs = cli.CommandDocumentationContent{
@@ -75,7 +77,8 @@ func (cmd InitCmd) ArgParser() *argparser.ArgParser {
ap.SupportsString(emailParamName, "", "email", fmt.Sprintf("The email address used. If not provided will be taken from {{.EmphasisLeft}}%s{{.EmphasisRight}} in the global config.", env.UserEmailKey))
ap.SupportsString(cli.DateParam, "", "date", "Specify the date used in the initial commit. If not specified the current system time is used.")
ap.SupportsString(initBranchParamName, "b", "branch", fmt.Sprintf("The branch name used to initialize this database. If not provided will be taken from {{.EmphasisLeft}}%s{{.EmphasisRight}} in the global config. If unset, the default initialized branch will be named '%s'.", env.InitBranchName, env.DefaultInitBranch))
ap.SupportsFlag(cli.NewFormatFlag, "", fmt.Sprintf("Specify this flag to use the new storage format (%s).", types.Format_DOLT.VersionString()))
ap.SupportsFlag(newFormatFlag, "", fmt.Sprintf("Specify this flag to use the new storage format (%s).", types.Format_DOLT.VersionString()))
ap.SupportsFlag(oldFormatFlag, "", fmt.Sprintf("Specify this flag to use the old storage format (%s).", types.Format_LD_1.VersionString()))
return ap
}
@@ -89,9 +92,15 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d
cli.PrintErrln(color.RedString("This directory has already been initialized."))
return 1
}
if apr.Contains(cli.NewFormatFlag) {
if apr.Contains(newFormatFlag) && apr.Contains(oldFormatFlag) {
e := fmt.Sprintf("options %s and %s are mutually exclusive", newFormatFlag, oldFormatFlag)
cli.PrintErrln(color.RedString(e))
return 1
}
if apr.Contains(newFormatFlag) {
types.Format_Default = types.Format_DOLT
} else if apr.Contains(oldFormatFlag) {
types.Format_Default = types.Format_LD_1
}
name, _ := apr.GetValue(usernameParamName)