diff --git a/bats/no-repo.bats b/bats/no-repo.bats index b9a6342641..b7be13bdd0 100755 --- a/bats/no-repo.bats +++ b/bats/no-repo.bats @@ -53,6 +53,33 @@ teardown() { [[ "$output" =~ "gc - Cleans up unreferenced data from the repository." ]] || false } +@test "check all commands for valid help text" { + # pipe all commands to a file + # cut -s suppresses the line if it doesn't contain the delim + dolt | cut -f 1 -d " - " -s | sed "s/ //g" > all.txt + + # filter out commands without "-h" + cat all.txt \ + | sed "s/creds//g" \ + | sed "s/version//g" \ + | sed "s/schema//g" \ + | sed "s/table//g" \ + | sed "s/conflicts//g" \ + > commands.txt + + cat commands.txt | while IFS= read -r cmd; + do + if [ -z "$cmd" ]; then + continue + fi + + run dolt "$cmd" -h + [ "$status" -eq 0 ] + [[ "$output" =~ "NAME" ]] || false + [[ "$output" =~ "DESCRIPTION" ]] || false + done +} + @test "testing dolt version output" { run dolt version [ "$status" -eq 0 ] diff --git a/go/cmd/dolt/commands/gc.go b/go/cmd/dolt/commands/gc.go index bc854fe2f8..cf85f20695 100644 --- a/go/cmd/dolt/commands/gc.go +++ b/go/cmd/dolt/commands/gc.go @@ -34,7 +34,7 @@ const ( var gcDocs = cli.CommandDocumentationContent{ ShortDesc: "Cleans up unreferenced data from the repository.", - LongDesc: `Searches the repository for data that is no longer referenced and no longer needed + LongDesc: `Searches the repository for data that is no longer referenced and no longer needed. If the {{.EmphasisLeft}}--shallow{{.EmphasisRight}} flag is supplied, a faster but less thorough garbage collection will be performed.`, Synopsis: []string{ @@ -83,14 +83,10 @@ func (cmd GarbageCollectionCmd) Exec(ctx context.Context, commandStr string, arg var verr errhand.VerboseError ap := cmd.createArgParser() - _, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, lsDocs, ap)) - apr, err := ap.Parse(args) - - if err != nil { - verr = errhand.VerboseErrorFromError(err) - return HandleVErrAndExitCode(verr, usage) - } + help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, gcDocs, ap)) + apr := cli.ParseArgs(ap, args, help) + var err error if apr.Contains(gcShallowFlag) { db, ok := dEnv.DoltDB.ValueReadWriter().(datas.Database) if !ok {