diff --git a/go/cmd/dolt/cli/documentation_helper.go b/go/cmd/dolt/cli/documentation_helper.go
index acb00ee9a2..dc214ac045 100644
--- a/go/cmd/dolt/cli/documentation_helper.go
+++ b/go/cmd/dolt/cli/documentation_helper.go
@@ -25,25 +25,20 @@ import (
type commandDocumentForMarkdown struct {
Command string
- CommandAndShortDesc string
+ ShortDesc string
Synopsis string
Description string
Options string
}
-var cmdMdDocTempl = `## Command
-{{.CommandAndShortDesc}}
-
-### Synopsis
-{{.Synopsis}}
-
-### Description
-{{.Description}}
-
-### Options
-{{.Options}}
-
-`
+var cmdMdDocTempl = "## `{{.Command}}`\n\n" +
+ "{{.ShortDesc}}\n\n" +
+ "### Synopsis\n\n" +
+ "{{.Synopsis}}\n\n" +
+ "### Description\n\n" +
+ "{{.Description}}\n\n" +
+ "### Options\n\n" +
+ "{{.Options}}\n\n"
func (cmdDoc CommandDocumentation) CmdDocToMd() (string, error) {
@@ -124,11 +119,11 @@ func (cmdDoc CommandDocumentation) cmdDocToCmdDocMd(options string) (commandDocu
}
return commandDocumentForMarkdown{
- Command: cmdDoc.CommandStr,
- CommandAndShortDesc: fmt.Sprintf("`%s` - %s\n\n", cmdDoc.CommandStr, cmdDoc.GetShortDesc()),
- Synopsis: transformSynopsisToMarkdown(cmdDoc.CommandStr, synopsis),
- Description: longDesc,
- Options: options,
+ Command: cmdDoc.CommandStr,
+ ShortDesc: cmdDoc.GetShortDesc(),
+ Synopsis: transformSynopsisToMarkdown(cmdDoc.CommandStr, synopsis),
+ Description: longDesc,
+ Options: options,
}, nil
}
@@ -199,16 +194,16 @@ func transformSynopsisToMarkdown(commandStr string, synopsis []string) string {
if len(synopsis) == 0 {
return ""
}
- synopsisStr := fmt.Sprintf("%s %s
\n", commandStr, synopsis[0])
+ synopsisStr := fmt.Sprintf("%s %s\n", commandStr, synopsis[0])
if len(synopsis) > 1 {
temp := make([]string, len(synopsis)-1)
for i, el := range synopsis[1:] {
- temp[i] = fmt.Sprintf("\t\t\t%s %s
\n", commandStr, el)
+ temp[i] = fmt.Sprintf("%s %s\n", commandStr, el)
}
synopsisStr += strings.Join(temp, "")
}
- markdown := "```bash\n%s\n```"
+ markdown := "```bash\n%s```"
return fmt.Sprintf(markdown, synopsisStr)
}
diff --git a/go/cmd/dolt/commands/dump_docs.go b/go/cmd/dolt/commands/dump_docs.go
index 6240c60571..6bc1fa55f4 100644
--- a/go/cmd/dolt/commands/dump_docs.go
+++ b/go/cmd/dolt/commands/dump_docs.go
@@ -24,7 +24,6 @@ import (
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
"github.com/dolthub/dolt/go/libraries/doltcore/env"
"github.com/dolthub/dolt/go/libraries/utils/argparser"
- "github.com/dolthub/dolt/go/libraries/utils/iohelp"
)
const (
@@ -68,7 +67,7 @@ func (cmd *DumpDocsCmd) Exec(_ context.Context, commandStr string, args []string
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, cli.CommandDocumentationContent{}, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
- fileStr := apr.GetValueOrDefault(fileParamName, ".")
+ fileStr := apr.GetValueOrDefault(fileParamName, "cli.md")
exists, _ := dEnv.FS.Exists(fileStr)
if exists {
@@ -77,7 +76,13 @@ func (cmd *DumpDocsCmd) Exec(_ context.Context, commandStr string, args []string
return 1
}
- err := cmd.dumpDocs(dEnv, fileStr, cmd.DoltCommand.Name(), cmd.DoltCommand.Subcommands)
+ wr, err := dEnv.FS.OpenForWrite(fileStr, os.ModePerm)
+ if err != nil {
+ cli.PrintErrln(err.Error())
+ return 1
+ }
+
+ err = cmd.dumpDocs(wr, cmd.DoltCommand.Name(), cmd.DoltCommand.Subcommands)
if err != nil {
verr := errhand.BuildDError("error: Failed to dump docs.").AddCause(err).Build()
@@ -89,13 +94,7 @@ func (cmd *DumpDocsCmd) Exec(_ context.Context, commandStr string, args []string
return 0
}
-func (cmd *DumpDocsCmd) dumpDocs(dEnv *env.DoltEnv, fileStr, cmdStr string, subCommands []cli.Command) error {
-
- wr, err := dEnv.FS.OpenForWrite(fileStr, os.ModePerm)
- if err != nil {
- return err
- }
-
+func (cmd *DumpDocsCmd) dumpDocs(wr io.Writer, cmdStr string, subCommands []cli.Command) error {
for _, curr := range subCommands {
var hidden bool
if hidCmd, ok := curr.(cli.HiddenCommand); ok {
@@ -104,7 +103,7 @@ func (cmd *DumpDocsCmd) dumpDocs(dEnv *env.DoltEnv, fileStr, cmdStr string, subC
if !hidden {
if subCmdHandler, ok := curr.(cli.SubCommandHandler); ok {
- err := cmd.dumpDocs(dEnv, fileStr, cmdStr+" "+subCmdHandler.Name(), subCmdHandler.Subcommands)
+ err := cmd.dumpDocs(wr, cmdStr+" "+subCmdHandler.Name(), subCmdHandler.Subcommands)
if err != nil {
return err
@@ -128,5 +127,6 @@ func CreateMarkdown(wr io.Writer, cmdDoc cli.CommandDocumentation) error {
if err != nil {
return err
}
- return iohelp.WriteIfNoErr(wr, []byte(markdownDoc), err)
+ _, err = wr.Write([]byte(markdownDoc))
+ return err
}
diff --git a/go/cmd/dolt/commands/reset.go b/go/cmd/dolt/commands/reset.go
index 4422142500..43150c785e 100644
--- a/go/cmd/dolt/commands/reset.go
+++ b/go/cmd/dolt/commands/reset.go
@@ -35,20 +35,19 @@ const (
var resetDocContent = cli.CommandDocumentationContent{
ShortDesc: "Resets staged tables to their HEAD state",
- LongDesc: `Sets the state of a table in the staging area to be that table's value at HEAD
-
-{{.EmphasisLeft}}dolt reset ...{{.EmphasisRight}}"
- This form resets the values for all staged {{.LessThan}}tables{{.GreaterThan}} to their values at {{.EmphasisLeft}}HEAD{{.EmphasisRight}}. (It does not affect the working tree or
- the current branch.)
-
- This means that {{.EmphasisLeft}}dolt reset {{.EmphasisRight}} is the opposite of {{.EmphasisLeft}}dolt add {{.EmphasisRight}}.
-
- After running {{.EmphasisLeft}}dolt reset {{.EmphasisRight}} to update the staged tables, you can use {{.EmphasisLeft}}dolt checkout{{.EmphasisRight}} to check the
- contents out of the staged tables to the working tables.
-
-dolt reset .
- This form resets {{.EmphasisLeft}}all{{.EmphasisRight}} staged tables to their values at HEAD. It is the opposite of {{.EmphasisLeft}}dolt add .{{.EmphasisRight}}`,
-
+ LongDesc: "Sets the state of a table in the staging area to be that table's value at HEAD\n\n" +
+ "{{.EmphasisLeft}}dolt reset ...{{.EmphasisRight}}" +
+ "\n\n" +
+ "This form resets the values for all staged {{.LessThan}}tables{{.GreaterThan}} to their values at {{.EmphasisLeft}}HEAD{{.EmphasisRight}}. " +
+ "It does not affect the working tree or the current branch." +
+ "\n\n" +
+ "This means that {{.EmphasisLeft}}dolt reset {{.EmphasisRight}} is the opposite of {{.EmphasisLeft}}dolt add {{.EmphasisRight}}." +
+ "\n\n" +
+ "After running {{.EmphasisLeft}}dolt reset {{.EmphasisRight}} to update the staged tables, you can use {{.EmphasisLeft}}dolt checkout{{.EmphasisRight}} to check the contents out of the staged tables to the working tables." +
+ "\n\n" +
+ "{{.EmphasisLeft}}dolt reset .{{.EmphasisRight}}" +
+ "\n\n" +
+ "This form resets {{.EmphasisLeft}}all{{.EmphasisRight}} staged tables to their values at HEAD. It is the opposite of {{.EmphasisLeft}}dolt add .{{.EmphasisRight}}",
Synopsis: []string{
"{{.LessThan}}tables{{.GreaterThan}}...",
"[--hard | --soft]",
diff --git a/go/cmd/dolt/commands/sqlserver/sqlserver.go b/go/cmd/dolt/commands/sqlserver/sqlserver.go
index 923ea195f5..6138828c63 100644
--- a/go/cmd/dolt/commands/sqlserver/sqlserver.go
+++ b/go/cmd/dolt/commands/sqlserver/sqlserver.go
@@ -20,6 +20,7 @@ import (
"fmt"
"io"
"strconv"
+ "strings"
"github.com/fatih/color"
@@ -46,6 +47,17 @@ const (
maxConnectionsFlag = "max-connections"
)
+func indentLines(s string) string {
+ sb := strings.Builder{}
+ lines := strings.Split(s, "\n")
+ for _, line := range lines {
+ sb.WriteRune('\t')
+ sb.WriteString(line)
+ sb.WriteRune('\n')
+ }
+ return sb.String()
+}
+
var sqlServerDocs = cli.CommandDocumentationContent{
ShortDesc: "Start a MySQL-compatible server.",
LongDesc: "By default, starts a MySQL-compatible server on the dolt database in the current directory. " +
@@ -55,7 +67,7 @@ var sqlServerDocs = cli.CommandDocumentationContent{
"the server directly on the command line. If {{.EmphasisLeft}}--config {{.EmphasisRight}} is provided all" +
" other command line arguments are ignored.\n\nThis is an example yaml configuration file showing all supported" +
" items and their default values:\n\n" +
- serverConfigAsYAMLConfig(DefaultServerConfig()).String() + "\n\n" + `
+ indentLines(serverConfigAsYAMLConfig(DefaultServerConfig()).String()) + "\n\n" + `
SUPPORTED CONFIG FILE FIELDS:
{{.EmphasisLeft}}vlog_level{{.EmphasisRight}} - Level of logging provided. Options are: {{.EmphasisLeft}}trace{{.EmphasisRight}}, {{.EmphasisLeft}}debug{{.EmphasisRight}}, {{.EmphasisLeft}}info{{.EmphasisRight}}, {{.EmphasisLeft}}warning{{.EmphasisRight}}, {{.EmphasisLeft}}error{{.EmphasisRight}}, and {{.EmphasisLeft}}fatal{{.EmphasisRight}}.
diff --git a/go/cmd/dolt/dolt.go b/go/cmd/dolt/dolt.go
index 59ee9b9c3a..21751def94 100644
--- a/go/cmd/dolt/dolt.go
+++ b/go/cmd/dolt/dolt.go
@@ -57,33 +57,32 @@ var doltCommand = cli.NewSubCommandHandler("dolt", "it's git for data", []cli.Co
commands.InitCmd{},
commands.StatusCmd{},
commands.AddCmd{},
+ commands.DiffCmd{},
commands.ResetCmd{},
commands.CommitCmd{},
commands.SqlCmd{VersionStr: Version},
sqlserver.SqlServerCmd{VersionStr: Version},
sqlserver.SqlClientCmd{},
commands.LogCmd{},
- commands.DiffCmd{},
- commands.BlameCmd{},
- commands.MergeCmd{},
commands.BranchCmd{},
- commands.TagCmd{},
commands.CheckoutCmd{},
+ commands.MergeCmd{},
+ cnfcmds.Commands,
+ commands.RevertCmd{},
+ commands.CloneCmd{},
+ commands.FetchCmd{},
+ commands.PullCmd{},
+ commands.PushCmd{},
+ commands.ConfigCmd{},
commands.RemoteCmd{},
commands.BackupCmd{},
- commands.PushCmd{},
- commands.PullCmd{},
- commands.FetchCmd{},
- commands.CloneCmd{},
- commands.RevertCmd{},
- credcmds.Commands,
commands.LoginCmd{},
- commands.VersionCmd{VersionStr: Version},
- commands.ConfigCmd{},
+ credcmds.Commands,
commands.LsCmd{},
schcmds.Commands,
tblcmds.Commands,
- cnfcmds.Commands,
+ commands.TagCmd{},
+ commands.BlameCmd{},
cvcmds.Commands,
commands.SendMetricsCmd{},
dumpDocsCommand,
@@ -94,6 +93,7 @@ var doltCommand = cli.NewSubCommandHandler("dolt", "it's git for data", []cli.Co
commands.FilterBranchCmd{},
commands.MergeBaseCmd{},
commands.RootsCmd{},
+ commands.VersionCmd{VersionStr: Version},
})
func init() {