dolt init fails with invalid arguments (#4815)

This commit is contained in:
jennifersp
2022-11-18 09:22:41 -08:00
committed by GitHub
parent 911801e743
commit d1d1928f15
2 changed files with 17 additions and 0 deletions

View File

@@ -88,6 +88,11 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
if len(apr.Args) > 0 {
cli.PrintErrln(color.RedString("error: invalid arguments."))
return 1
}
if dEnv.HasDoltDir() {
cli.PrintErrln(color.RedString("This directory has already been initialized."))
return 1

View File

@@ -152,6 +152,18 @@ teardown() {
[ "$status" -eq 1 ]
}
@test "init: running init with invalid argument or option fails" {
set_dolt_user "baz", "baz@bash.com"
run dolt init invalid
[ "$status" -eq 1 ]
[[ "$output" =~ "error: invalid arguments" ]] || false
run dolt init --invalid
[ "$status" -eq 1 ]
[[ "$output" =~ "error: unknown option" ]] || false
}
@test "init: running init with the new format, creates a new format database" {
set_dolt_user "baz", "baz@bash.com"