Merge pull request #932 from dolthub/andy/gc-help-text-fix

/go/cmd/dolt/commands: Help Text Fix
This commit is contained in:
AndyA
2020-10-14 16:32:06 -07:00
committed by GitHub
2 changed files with 31 additions and 8 deletions

View File

@@ -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 ]

View File

@@ -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 {