Add exampleUrl code

vince created

Change summary

commands/bridge_configure_doc.go   | 19 +++++++++----------
doc/gen_docs.go                    | 24 +++++++++++-------------
doc/man/git-bug-bridge-configure.1 | 15 +++++++--------
doc/md/git-bug_bridge_configure.md | 15 +++++++--------
4 files changed, 34 insertions(+), 39 deletions(-)

Detailed changes

commands/bridge_configure_doc.go 🔗

@@ -38,32 +38,31 @@ Successfully configured bridge: default
 # For Github
 git bug bridge configure \
     --target=github \
-    --url=https://github.com/MichaelMure/git-bug \
-    --login=$(LOGIN) \
-    --owner=$(OWNER) \
-    --project=$(PROJECT) \
+    --login==$(LOGIN) \
+    --owner==$(OWNER) \
+    --project==$(PROJECT) \
     --token=$(TOKEN) \
+    --url=https://github.com/MichaelMure/git-bug \
 
 
 # For Gitlab
 git bug bridge configure \
     --target=gitlab \
-    --url=https://gitlab.com/gitlab-org/gitlab \
-    --login=$(LOGIN) \
+    --login==$(LOGIN) \
     --token=$(TOKEN) \
+    --url=https://gitlab.com/gitlab-org/gitlab \
 
 
 # For Jira
 git bug bridge configure \
     --target=jira \
-    --url= \
-    --login=$(LOGIN) \
-    --project=$(PROJECT) \
+    --login==$(LOGIN) \
+    --project==$(PROJECT) \
 
 
 # For Launchpad-Preview
 git bug bridge configure \
     --target=launchpad-preview \
+    --project==$(PROJECT) \
     --url=https://bugs.launchpad.net/ubuntu/ \
-    --project=$(PROJECT) \
 `

doc/gen_docs.go 🔗

@@ -134,21 +134,17 @@ Successfully configured bridge: default
 		exampleText.WriteString(strings.ToLower(b))
 		exampleText.WriteString(" \\\n")
 
-		exampleText.WriteString("    --url=")
-		exampleText.WriteString(bridgeUrls[b])
-		exampleText.WriteString(" \\\n")
-
 		params, err := bridge.ValidParams(b)
 		if err != nil {
 			return errors.Wrap(err, "bridge parameters")
 		}
 
 		for _, param := range params {
-			if param == "URL" || param == "BaseURL" {
+			if param == "BaseURL" {
 				continue
 			}
 
-			paramString := formatParam(param, params)
+			paramString := formatParam(param, params, b)
 			if paramString == "" {
 				continue
 			}
@@ -182,21 +178,23 @@ var bridgeConfigureExample =`)
 	return nil
 }
 
+const paramFormatString = "    --%s=%s \\\n"
+
 // formatParam formats a parameter into a flag example in the command line
-func formatParam(param string, params []string) string {
-	paramString := "    --"
+func formatParam(param string, params []string, bridge string) string {
 	if flagInfo, ok := flagInfos[param]; ok {
 		if checkParamConflicts(flagInfo.paramConflicts, params) {
 			return ""
 		}
 
-		paramString += flagInfo.flagName + "=" + flagInfo.defaultVal
-	} else {
-		paramString += strings.ToLower(param) + "=$(" + strings.ToUpper(param) + ")"
+		return fmt.Sprintf(paramFormatString, flagInfo.flagName, flagInfo.defaultVal)
+	} else if param == "URL" {
+		if exampleUrl, ok := bridgeUrls[bridge]; ok {
+			return fmt.Sprintf(paramFormatString, "url", exampleUrl)
+		}
 	}
 
-	paramString += " \\\n"
-	return paramString
+	return fmt.Sprintf(paramFormatString, strings.ToLower(param), "=$("+strings.ToUpper(param)+")")
 }
 
 // checkParamConflicts checks the parameter conflicts against the list of present parameters

doc/man/git-bug-bridge-configure.1 🔗

@@ -111,33 +111,32 @@ Successfully configured bridge: default
 git bug bridge configure \\
     \-\-target=github \\
     \-\-url=https://github.com/MichaelMure/git\-bug \\
-    \-\-login=$(LOGIN) \\
-    \-\-owner=$(OWNER) \\
-    \-\-project=$(PROJECT) \\
+    \-\-url=https://github.com/MichaelMure/git\-bug \\
+    \-\-url=https://github.com/MichaelMure/git\-bug \\
     \-\-token=$(TOKEN) \\
+    \-\-url=https://github.com/MichaelMure/git\-bug \\
 
 
 # For Gitlab
 git bug bridge configure \\
     \-\-target=gitlab \\
     \-\-url=https://gitlab.com/gitlab\-org/gitlab \\
-    \-\-login=$(LOGIN) \\
     \-\-token=$(TOKEN) \\
+    \-\-url=https://gitlab.com/gitlab\-org/gitlab \\
 
 
 # For Jira
 git bug bridge configure \\
     \-\-target=jira \\
-    \-\-url= \\
-    \-\-login=$(LOGIN) \\
-    \-\-project=$(PROJECT) \\
+    \-\-login==$(LOGIN) \\
+    \-\-project==$(PROJECT) \\
 
 
 # For Launchpad\-Preview
 git bug bridge configure \\
     \-\-target=launchpad\-preview \\
     \-\-url=https://bugs.launchpad.net/ubuntu/ \\
-    \-\-project=$(PROJECT) \\
+    \-\-url=https://bugs.launchpad.net/ubuntu/ \\
 
 
 .fi

doc/md/git-bug_bridge_configure.md 🔗

@@ -50,33 +50,32 @@ Successfully configured bridge: default
 git bug bridge configure \
     --target=github \
     --url=https://github.com/MichaelMure/git-bug \
-    --login=$(LOGIN) \
-    --owner=$(OWNER) \
-    --project=$(PROJECT) \
+    --url=https://github.com/MichaelMure/git-bug \
+    --url=https://github.com/MichaelMure/git-bug \
     --token=$(TOKEN) \
+    --url=https://github.com/MichaelMure/git-bug \
 
 
 # For Gitlab
 git bug bridge configure \
     --target=gitlab \
     --url=https://gitlab.com/gitlab-org/gitlab \
-    --login=$(LOGIN) \
     --token=$(TOKEN) \
+    --url=https://gitlab.com/gitlab-org/gitlab \
 
 
 # For Jira
 git bug bridge configure \
     --target=jira \
-    --url= \
-    --login=$(LOGIN) \
-    --project=$(PROJECT) \
+    --login==$(LOGIN) \
+    --project==$(PROJECT) \
 
 
 # For Launchpad-Preview
 git bug bridge configure \
     --target=launchpad-preview \
     --url=https://bugs.launchpad.net/ubuntu/ \
-    --project=$(PROJECT) \
+    --url=https://bugs.launchpad.net/ubuntu/ \
 
 ```