From 2af5d8cb80b87ce022928cd243ee9576c2c636a4 Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Tue, 13 Oct 2020 15:47:17 -0700 Subject: [PATCH 1/3] fix dolt gc help text and added help text BATS --- bats/no-repo.bats | 26 ++++++++++++++++++++++++++ go/cmd/dolt/commands/gc.go | 12 ++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/bats/no-repo.bats b/bats/no-repo.bats index b9a6342641..a1b1d710de 100755 --- a/bats/no-repo.bats +++ b/bats/no-repo.bats @@ -53,6 +53,32 @@ 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" > commands.txt + + # filter out commands without "-h" + sed -i .bak "s/remote//g" commands.txt + sed -i .bak "s/creds//g" commands.txt + sed -i .bak "s/version//g" commands.txt + sed -i .bak "s/schema//g" commands.txt + sed -i .bak "s/table//g" commands.txt + sed -i .bak "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 { From 7425cedb587b36e3bc467e7afe3d75b9a4743b70 Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Tue, 13 Oct 2020 17:18:44 -0700 Subject: [PATCH 2/3] pipeline ftw --- bats/no-repo.bats | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bats/no-repo.bats b/bats/no-repo.bats index a1b1d710de..56606d851b 100755 --- a/bats/no-repo.bats +++ b/bats/no-repo.bats @@ -56,15 +56,17 @@ teardown() { @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" > commands.txt + dolt | cut -f 1 -d " - " -s | sed "s/ //g" > all.txt # filter out commands without "-h" - sed -i .bak "s/remote//g" commands.txt - sed -i .bak "s/creds//g" commands.txt - sed -i .bak "s/version//g" commands.txt - sed -i .bak "s/schema//g" commands.txt - sed -i .bak "s/table//g" commands.txt - sed -i .bak "s/conflicts//g" commands.txt + cat all.txt \ + | sed "s/remote//g" \ + | 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 From 2dcc9da07697a7066bc1cae89c21cddce4589117 Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Wed, 14 Oct 2020 15:58:00 -0700 Subject: [PATCH 3/3] validate help text for dolt remote also --- bats/no-repo.bats | 1 - 1 file changed, 1 deletion(-) diff --git a/bats/no-repo.bats b/bats/no-repo.bats index 56606d851b..b7be13bdd0 100755 --- a/bats/no-repo.bats +++ b/bats/no-repo.bats @@ -60,7 +60,6 @@ teardown() { # filter out commands without "-h" cat all.txt \ - | sed "s/remote//g" \ | sed "s/creds//g" \ | sed "s/version//g" \ | sed "s/schema//g" \