Fixing this terrible interface

This commit is contained in:
Zach Musgrave
2022-06-15 13:00:38 -07:00
parent 7328631686
commit ef5e37eeaf
63 changed files with 115 additions and 124 deletions

View File

@@ -73,7 +73,7 @@ func ParseArgsOrDie(ap *argparser.ArgParser, args []string, usagePrinter UsagePr
return apr
}
func HelpAndUsagePrinters(cmdDoc CommandDocumentation) (UsagePrinter, UsagePrinter) {
func HelpAndUsagePrinters(cmdDoc *CommandDocumentation) (UsagePrinter, UsagePrinter) {
// TODO handle error states
longDesc, _ := cmdDoc.GetLongDesc(CliFormat)
synopsis, _ := cmdDoc.GetSynopsis(CliFormat)

View File

@@ -17,7 +17,6 @@ package cli
import (
"context"
"fmt"
"io"
"os"
"os/signal"
"strings"
@@ -66,8 +65,8 @@ type Command interface {
Description() string
// Exec executes the command
Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
CreateMarkdown(writer io.Writer, commandStr string) error
// Docs returns the documentation for this command, or nil if it's undocumented
Docs() *CommandDocumentation
// ArgParser returns the arg parser for this command
ArgParser() *argparser.ArgParser
}
@@ -158,7 +157,7 @@ func (hc SubCommandHandler) RequiresRepo() bool {
return false
}
func (hc SubCommandHandler) CreateMarkdown(_ io.Writer, _ string) error {
func (hc SubCommandHandler) Docs() *CommandDocumentation {
return nil
}

View File

@@ -61,7 +61,7 @@ func (cmd *trackedCommand) Description() string {
return cmd.description
}
func (cmd *trackedCommand) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd *trackedCommand) Docs() *CommandDocumentation {
return nil
}

View File

@@ -128,9 +128,18 @@ func (cmdDoc CommandDocumentation) cmdDocToCmdDocMd(options string) (commandDocu
}
// Creates a CommandDocumentation given command string, arg parser, and a CommandDocumentationContent
func GetCommandDocumentation(commandStr string, cmdDoc CommandDocumentationContent, argParser *argparser.ArgParser) CommandDocumentation {
return CommandDocumentation{
CommandStr: commandStr,
func GetCommandDocumentation(cmdDoc CommandDocumentationContent, argParser *argparser.ArgParser) *CommandDocumentation {
return &CommandDocumentation{
ShortDesc: cmdDoc.ShortDesc,
LongDesc: cmdDoc.LongDesc,
Synopsis: cmdDoc.Synopsis,
ArgParser: argParser,
}
}
func NewCommandDocumentation(command string, cmdDoc CommandDocumentationContent, argParser *argparser.ArgParser) *CommandDocumentation {
return &CommandDocumentation{
CommandStr: command,
ShortDesc: cmdDoc.ShortDesc,
LongDesc: cmdDoc.LongDesc,
Synopsis: cmdDoc.Synopsis,

View File

@@ -16,7 +16,6 @@ package commands
import (
"context"
"io"
"github.com/dolthub/dolt/go/cmd/dolt/cli"
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
@@ -51,10 +50,9 @@ func (cmd AddCmd) Description() string {
return "Add table changes to the list of staged table changes."
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd AddCmd) CreateMarkdown(writer io.Writer, commandStr string) error {
func (cmd AddCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateAddArgParser()
return CreateMarkdown(writer, cli.GetCommandDocumentation(commandStr, addDocs, ap))
return cli.GetCommandDocumentation(addDocs, ap)
}
func (cmd AddCmd) ArgParser() *argparser.ArgParser {
@@ -64,7 +62,7 @@ func (cmd AddCmd) ArgParser() *argparser.ArgParser {
// Exec executes the command
func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cli.CreateAddArgParser()
helpPr, _ := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, addDocs, ap))
helpPr, _ := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, addDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, helpPr)
if apr.ContainsArg(doltdb.DocTableName) {

View File

@@ -17,7 +17,6 @@ package commands
import (
"context"
"encoding/json"
"io"
"os"
"strings"
@@ -97,9 +96,9 @@ func (cmd BackupCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd BackupCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd BackupCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, backupDocs, ap))
return cli.GetCommandDocumentation(backupDocs, ap)
}
func (cmd BackupCmd) ArgParser() *argparser.ArgParser {
@@ -114,7 +113,7 @@ func (cmd BackupCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd BackupCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, backupDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, backupDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
var verr errhand.VerboseError

View File

@@ -93,7 +93,7 @@ func (cmd BlameCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd BlameCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd BlameCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, blameDocs, ap))
}

View File

@@ -17,7 +17,6 @@ package commands
import (
"context"
"fmt"
"io"
"sort"
"strings"
@@ -83,10 +82,9 @@ func (cmd BranchCmd) Description() string {
return "Create, list, edit, delete branches."
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd BranchCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd BranchCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, branchDocs, ap))
return cli.GetCommandDocumentation(branchDocs, ap)
}
func (cmd BranchCmd) ArgParser() *argparser.ArgParser {
@@ -113,7 +111,7 @@ func (cmd BranchCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd BranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, branchDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, branchDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
switch {

View File

@@ -62,7 +62,7 @@ func (cmd CheckoutCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd CheckoutCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd CheckoutCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateCheckoutArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, checkoutDocs, ap))
}

View File

@@ -57,7 +57,7 @@ func (cmd CleanCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd CleanCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd CleanCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateCleanArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, cleanDocContent, ap))
}

View File

@@ -71,7 +71,7 @@ func (cmd CloneCmd) RequiresRepo() bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd CloneCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd CloneCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, cloneDocs, ap))
}

View File

@@ -16,7 +16,6 @@ package cnfcmds
import (
"context"
"io"
"github.com/dolthub/dolt/go/store/types"
@@ -62,9 +61,9 @@ func (cmd CatCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd CatCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd CatCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, catDocs, ap))
return cli.GetCommandDocumentation(catDocs, ap)
}
// EventType returns the type of the event to log
@@ -82,7 +81,7 @@ func (cmd CatCmd) ArgParser() *argparser.ArgParser {
// Exec executes the command
func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, catDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, catDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
args = apr.Args

View File

@@ -16,7 +16,6 @@ package cnfcmds
import (
"context"
"io"
"strings"
eventsapi "github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi/v1alpha1"
@@ -82,10 +81,9 @@ func (cmd ResolveCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
return types.IsFormat_DOLT_1(nbf)
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ResolveCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ResolveCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, resDocumentation, ap))
return cli.GetCommandDocumentation(resDocumentation, ap)
}
// EventType returns the type of the event to log
@@ -106,7 +104,7 @@ func (cmd ResolveCmd) ArgParser() *argparser.ArgParser {
// Exec executes the command
func (cmd ResolveCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, resDocumentation, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, resDocumentation, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
var verr errhand.VerboseError

View File

@@ -67,7 +67,7 @@ func (cmd CommitCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd CommitCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd CommitCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateCommitArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, commitDocs, ap))
}

View File

@@ -73,7 +73,7 @@ func (cmd ConfigCmd) RequiresRepo() bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ConfigCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ConfigCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, cfgDocs, ap))
}

View File

@@ -55,7 +55,7 @@ func (cmd CheckCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd CheckCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd CheckCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, checkDocs, ap))
}

View File

@@ -64,7 +64,7 @@ func (cmd ImportCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ImportCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ImportCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, importDocs, ap))
}

View File

@@ -53,7 +53,7 @@ func (cmd LsCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd LsCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd LsCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, lsDocs, ap))
}

View File

@@ -16,7 +16,6 @@ package credcmds
import (
"context"
"io"
"github.com/dolthub/dolt/go/cmd/dolt/cli"
"github.com/dolthub/dolt/go/cmd/dolt/commands"
@@ -50,9 +49,9 @@ func (cmd NewCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd NewCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd NewCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, newDocs, ap))
return cli.GetCommandDocumentation(newDocs, ap)
}
// RequiresRepo should return false if this interface is implemented, and the command does not have the requirement
@@ -74,7 +73,7 @@ func (cmd NewCmd) ArgParser() *argparser.ArgParser {
// Exec executes the command
func (cmd NewCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, newDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, newDocs, ap))
cli.ParseArgsOrDie(ap, args, help)
_, newCreds, verr := actions.NewCredsFile(dEnv)

View File

@@ -47,7 +47,7 @@ func (cmd RmCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd RmCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd RmCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, rmDocs, ap))
}

View File

@@ -53,7 +53,7 @@ func (cmd UseCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd UseCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd UseCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, useDocs, ap))
}

View File

@@ -62,7 +62,7 @@ func (cmd VerifyConstraintsCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
return types.IsFormat_DOLT_1(nbf)
}
func (cmd VerifyConstraintsCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd VerifyConstraintsCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, verifyConstraintsDocs, ap))
}

View File

@@ -131,7 +131,7 @@ func (cmd DiffCmd) EventType() eventsapi.ClientEventType {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd DiffCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd DiffCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, diffDocs, ap))
}

View File

@@ -17,7 +17,6 @@ package commands
import (
"context"
"fmt"
"io"
"os"
"path/filepath"
"strings"
@@ -77,9 +76,9 @@ func (cmd DumpCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the help text for the command at the given path
func (cmd DumpCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd DumpCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, dumpDocs, ap))
return cli.GetCommandDocumentation(dumpDocs, ap)
}
func (cmd DumpCmd) ArgParser() *argparser.ArgParser {
@@ -101,7 +100,7 @@ func (cmd DumpCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, dumpDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, dumpDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
if apr.NArg() > 0 {

View File

@@ -67,7 +67,7 @@ func (cmd *DumpDocsCmd) RequiresRepo() bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd *DumpDocsCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd *DumpDocsCmd) Docs() *cli.CommandDocumentation {
return nil
}
@@ -132,11 +132,14 @@ func (cmd *DumpDocsCmd) dumpDocs(wr io.Writer, cmdStr string, subCommands []cli.
return err
}
} else {
currCmdStr := fmt.Sprintf("%s %s", cmdStr, curr.Name())
err := curr.CreateMarkdown(wr, currCmdStr)
docs := curr.Docs()
if err != nil {
return err
if docs != nil {
docs.CommandStr = fmt.Sprintf("%s %s", cmdStr, curr.Name())
err := CreateMarkdown(wr, docs)
if err != nil {
return err
}
}
}
}
@@ -145,7 +148,7 @@ func (cmd *DumpDocsCmd) dumpDocs(wr io.Writer, cmdStr string, subCommands []cli.
return nil
}
func CreateMarkdown(wr io.Writer, cmdDoc cli.CommandDocumentation) error {
func CreateMarkdown(wr io.Writer, cmdDoc *cli.CommandDocumentation) error {
markdownDoc, err := cmdDoc.CmdDocToMd()
if err != nil {
return err

View File

@@ -66,7 +66,7 @@ func (cmd FetchCmd) EventType() eventsapi.ClientEventType {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd FetchCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd FetchCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateFetchArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, fetchDocs, ap))
}

View File

@@ -82,7 +82,7 @@ func (cmd FilterBranchCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd FilterBranchCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd FilterBranchCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, filterBranchDocs, ap))
}

View File

@@ -76,7 +76,7 @@ func (cmd GarbageCollectionCmd) RequiresRepo() bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd GarbageCollectionCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd GarbageCollectionCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, gcDocs, ap))
}

View File

@@ -255,7 +255,7 @@ func formatOption(opt *argparser.Option) string {
}
}
func (z GenZshCompCmd) CreateMarkdown(writer io.Writer, commandStr string) error {
func (z GenZshCompCmd) Docs() *cli.CommandDocumentation {
return nil
}

View File

@@ -75,7 +75,7 @@ func (cmd CatCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
return types.IsFormat_DOLT_1(nbf)
}
func (cmd CatCmd) CreateMarkdown(_ io.Writer, _ string) error {
func (cmd CatCmd) Docs() *cli.CommandDocumentation {
return nil
}

View File

@@ -52,7 +52,7 @@ func (cmd LsCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
return types.IsFormat_DOLT_1(nbf)
}
func (cmd LsCmd) CreateMarkdown(_ io.Writer, _ string) error {
func (cmd LsCmd) Docs() *cli.CommandDocumentation {
return nil
}

View File

@@ -16,7 +16,6 @@ package indexcmds
import (
"context"
"io"
"github.com/dolthub/dolt/go/store/types"
@@ -52,7 +51,7 @@ func (cmd RebuildCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
return types.IsFormat_DOLT_1(nbf)
}
func (cmd RebuildCmd) CreateMarkdown(_ io.Writer, _ string) error {
func (cmd RebuildCmd) Docs() *cli.CommandDocumentation {
return nil
}

View File

@@ -66,7 +66,7 @@ func (cmd InitCmd) RequiresRepo() bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd InitCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd InitCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, initDocs, ap))
}

View File

@@ -62,8 +62,7 @@ func (cmd InspectCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
return types.IsFormat_DOLT_1(nbf)
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd InspectCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd InspectCmd) Docs() *cli.CommandDocumentation {
return nil
}
@@ -76,7 +75,7 @@ func (cmd InspectCmd) ArgParser() *argparser.ArgParser {
// Exec executes the command
func (cmd InspectCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, cli.CommandDocumentationContent{}, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, cli.CommandDocumentationContent{}, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
var verr errhand.VerboseError

View File

@@ -87,7 +87,7 @@ func (cmd LogCmd) EventType() eventsapi.ClientEventType {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd LogCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd LogCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, logDocs, ap))
}

View File

@@ -17,7 +17,6 @@ package commands
import (
"context"
"fmt"
"io"
"strconv"
"time"
@@ -74,10 +73,9 @@ func (cmd LoginCmd) RequiresRepo() bool {
return false
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd LoginCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd LoginCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, loginDocs, ap))
return cli.GetCommandDocumentation(loginDocs, ap)
}
func (cmd LoginCmd) ArgParser() *argparser.ArgParser {
@@ -97,7 +95,7 @@ func (cmd LoginCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, loginDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, loginDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
// use config values over defaults, flag values over config values

View File

@@ -60,9 +60,9 @@ func (cmd LsCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd LsCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd LsCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, lsDocs, ap))
return cli.GetCommandDocumentation(lsDocs, ap)
}
func (cmd LsCmd) ArgParser() *argparser.ArgParser {
@@ -81,7 +81,7 @@ func (cmd LsCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, lsDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, lsDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
if apr.Contains(systemFlag) && apr.Contains(allFlag) {

View File

@@ -18,7 +18,6 @@ import (
"context"
"errors"
"fmt"
"io"
"sort"
"strconv"
@@ -63,10 +62,9 @@ func (cmd MergeCmd) Description() string {
return "Merge a branch."
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd MergeCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd MergeCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateMergeArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, mergeDocs, ap))
return cli.GetCommandDocumentation(mergeDocs, ap)
}
func (cmd MergeCmd) ArgParser() *argparser.ArgParser {
@@ -81,7 +79,7 @@ func (cmd MergeCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cli.CreateMergeArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, mergeDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, mergeDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
if apr.ContainsAll(cli.SquashParam, cli.NoFFParam) {

View File

@@ -50,7 +50,7 @@ func (cmd MergeBaseCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd MergeBaseCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd MergeBaseCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, mergeBaseDocs, ap))
}

View File

@@ -16,7 +16,6 @@ package commands
import (
"context"
"io"
"github.com/fatih/color"
@@ -58,8 +57,7 @@ func (cmd MigrateCmd) Description() string {
return migrateDocs.ShortDesc
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd MigrateCmd) CreateMarkdown(_ io.Writer, _ string) error {
func (cmd MigrateCmd) Docs() *cli.CommandDocumentation {
return nil
}
@@ -78,7 +76,7 @@ func (cmd MigrateCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd MigrateCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, _ := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, migrateDocs, ap))
help, _ := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, migrateDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
if apr.Contains(migratePushFlag) && apr.Contains(migratePullFlag) {

View File

@@ -59,7 +59,7 @@ func (cmd PullCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd PullCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd PullCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreatePullArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, pullDocs, ap))
}

View File

@@ -72,7 +72,7 @@ func (cmd PushCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd PushCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd PushCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, pushDocs, ap))
}

View File

@@ -62,7 +62,7 @@ func (cmd ReadTablesCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ReadTablesCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ReadTablesCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, readTablesDocs, ap))
}

View File

@@ -89,7 +89,7 @@ func (cmd RemoteCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd RemoteCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd RemoteCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, remoteDocs, ap))
}

View File

@@ -73,7 +73,7 @@ func (cmd ResetCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ResetCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ResetCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateResetArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, resetDocContent, ap))
}

View File

@@ -62,7 +62,7 @@ func (cmd RevertCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown implements the interface cli.Command.
func (cmd RevertCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd RevertCmd) Docs() *cli.CommandDocumentation {
ap := cli.CreateRevertArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, revertDocs, ap))
}

View File

@@ -70,7 +70,7 @@ func (cmd RootsCmd) GatedForNBF(nbf *types.NomsBinFormat) bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd RootsCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd RootsCmd) Docs() *cli.CommandDocumentation {
return nil
}

View File

@@ -57,9 +57,9 @@ func (cmd ExportCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ExportCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ExportCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, schExportDocs, ap))
return cli.GetCommandDocumentation(schExportDocs, ap)
}
func (cmd ExportCmd) ArgParser() *argparser.ArgParser {
@@ -77,7 +77,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, schExportDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, schExportDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
root, verr := commands.GetWorkingWithVErr(dEnv)

View File

@@ -137,7 +137,7 @@ func (cmd ImportCmd) EventType() eventsapi.ClientEventType {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ImportCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ImportCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, schImportDocs, ap))
}

View File

@@ -57,7 +57,7 @@ func (cmd ShowCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ShowCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ShowCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, tblSchemaDocs, ap))
}

View File

@@ -52,7 +52,7 @@ func (cmd TagsCmd) Description() string {
return "Shows the column tags of one or more tables."
}
func (cmd TagsCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd TagsCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, tblTagsDocs, ap))
}

View File

@@ -64,7 +64,7 @@ func (cmd SendMetricsCmd) Hidden() bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd SendMetricsCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd SendMetricsCmd) Docs() *cli.CommandDocumentation {
return nil
}

View File

@@ -127,7 +127,7 @@ func (cmd SqlCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd SqlCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd SqlCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, sqlDocs, ap))
}

View File

@@ -67,9 +67,9 @@ func (cmd SqlClientCmd) Description() string {
return "Starts a built-in MySQL client."
}
func (cmd SqlClientCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd SqlClientCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, sqlClientDocs, ap))
return cli.GetCommandDocumentation(sqlClientDocs, ap)
}
func (cmd SqlClientCmd) ArgParser() *argparser.ArgParser {
@@ -88,7 +88,7 @@ func (cmd SqlClientCmd) Hidden() bool {
func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, _ := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, sqlClientDocs, ap))
help, _ := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, sqlClientDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
var serverConfig ServerConfig

View File

@@ -122,7 +122,7 @@ func (cmd SqlServerCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd SqlServerCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd SqlServerCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, sqlServerDocs, ap))
}

View File

@@ -16,7 +16,6 @@ package commands
import (
"context"
"io"
"github.com/dolthub/dolt/go/cmd/dolt/cli"
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
@@ -45,9 +44,9 @@ func (cmd StatusCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd StatusCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd StatusCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, statusDocs, ap))
return cli.GetCommandDocumentation(statusDocs, ap)
}
func (cmd StatusCmd) ArgParser() *argparser.ArgParser {
@@ -58,7 +57,7 @@ func (cmd StatusCmd) ArgParser() *argparser.ArgParser {
// Exec executes the command
func (cmd StatusCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
help, _ := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, statusDocs, ap))
help, _ := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, statusDocs, ap))
cli.ParseArgsOrDie(ap, args, help)
roots, err := dEnv.Roots(ctx)

View File

@@ -62,7 +62,7 @@ func (cmd TagCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd TagCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd TagCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, tagDocs, ap))
}

View File

@@ -52,7 +52,7 @@ func (cmd CpCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd CpCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd CpCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, tblCpDocs, ap))
}

View File

@@ -16,7 +16,6 @@ package tblcmds
import (
"context"
"io"
"os"
"path/filepath"
@@ -117,7 +116,7 @@ func getExportDestination(apr *argparser.ArgParseResults) mvdata.DataLocation {
}
func parseExportArgs(ap *argparser.ArgParser, commandStr string, args []string) (*exportOptions, errhand.VerboseError) {
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, exportDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, exportDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
if apr.NArg() == 0 {
@@ -163,9 +162,9 @@ func (cmd ExportCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ExportCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ExportCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, exportDocs, ap))
return cli.GetCommandDocumentation(exportDocs, ap)
}
func (cmd ExportCmd) ArgParser() *argparser.ArgParser {
@@ -185,7 +184,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType {
// Exec executes the command
func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
ap := cmd.ArgParser()
_, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, exportDocs, ap))
_, usage := cli.HelpAndUsagePrinters(cli.NewCommandDocumentation(commandStr, exportDocs, ap))
exOpts, verr := parseExportArgs(ap, commandStr, args)
if verr != nil {

View File

@@ -325,7 +325,7 @@ func (cmd ImportCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd ImportCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd ImportCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, importDocs, ap))
}

View File

@@ -55,7 +55,7 @@ func (cmd MvCmd) Description() string {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd MvCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd MvCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, tblMvDocs, ap))
}

View File

@@ -55,7 +55,7 @@ func (cmd RmCmd) EventType() eventsapi.ClientEventType {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd RmCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd RmCmd) Docs() *cli.CommandDocumentation {
ap := cmd.ArgParser()
return commands.CreateMarkdown(wr, cli.GetCommandDocumentation(commandStr, tblRmDocs, ap))
}

View File

@@ -50,7 +50,7 @@ func (cmd VersionCmd) RequiresRepo() bool {
}
// CreateMarkdown creates a markdown file containing the helptext for the command at the given path
func (cmd VersionCmd) CreateMarkdown(wr io.Writer, commandStr string) error {
func (cmd VersionCmd) Docs() *cli.CommandDocumentation {
return nil
}