diff --git a/commands/cli/helptext_test.go b/commands/cli/helptext_test.go new file mode 100644 index 000000000..aa8361f99 --- /dev/null +++ b/commands/cli/helptext_test.go @@ -0,0 +1,45 @@ +package cli + +import ( + "strings" + "testing" + + cmds "github.com/ipfs/go-ipfs/commands" +) + +func TestSynopsisGenerator(t *testing.T) { + command := &cmds.Command{ + Arguments: []cmds.Argument{ + cmds.StringArg("required", true, false, ""), + cmds.StringArg("variadic", false, true, ""), + }, + Options: []cmds.Option{ + cmds.StringOption("opt", "o", "Option"), + }, + Helptext: cmds.HelpText{ + SynopsisOptionsValues: map[string]string{ + "opt": "OPTION", + }, + }, + } + syn := generateSynopsis(command, "cmd") + t.Logf("Synopsis is: %s", syn) + if !strings.HasPrefix(syn, "cmd ") { + t.Fatal("Synopsis should start with command name") + } + if !strings.Contains(syn, "[--opt=