Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #72 from BreD1810/ft-help-pages
Browse files Browse the repository at this point in the history
Add help pages for each command
  • Loading branch information
profclems authored Aug 8, 2020
2 parents 7100a83 + 92c70e4 commit ea8ad25
Show file tree
Hide file tree
Showing 11 changed files with 410 additions and 51 deletions.
3 changes: 3 additions & 0 deletions cmd/glab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func main() {
// Parse the arguments in a map
for i := 1; i < argLen; i++ {
sp := strings.Split(strings.TrimLeft(cmdArgs[i], "-"), "=") // Trim preceding dashes and split key and value into map
if sp[0] == "h" {
sp[0] = "help"
}
if len(sp) > 0 {
if len(sp) > 1 {
arr[sp[0]] = sp[1]
Expand Down
41 changes: 1 addition & 40 deletions cmd/glab/utils/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ADDITIONAL COMMANDS
help: Help about any command
FLAGS
--help Show help for command
-h, --help Show help for command
--version Show glab version
EXAMPLES
Expand Down Expand Up @@ -49,42 +49,3 @@ FEEDBACK
Built with ❤ by Clement Sam <https://clementsam.tech>`)

}

//RepoHelp print help
func RepoHelp(message string) {

fmt.Println(message, `
USAGE
glab repo clone <owner/repo> [<dir>] [<options>] [<flags>]
OPTIONS
format: clone the repository as archive ,use values [zip,tar]
FLAGS
--help Show help for command
--version Show glab version
EXAMPLES
$ glab repo clone profclems/glab mydrirectory
ENVIRONMENT VARIABLES
GITLAB_TOKEN: an authentication token for API requests. Setting this avoids being
prompted to authenticate and overrides any previously stored credentials.
GITLAB_REPO: specify the Gitlab repository in "OWNER/REPO" format for commands that
otherwise operate on a local repository.
GITLAB_URI: specify the url of the gitlab server if self hosted (eg: gitlab.example.com)
LEARN MORE
Use "glab <command> <subcommand> --help" for more information about a command.
Read the manual at https://glab.clementsam.tech
FEEDBACK
Open an issue using “glab issue create -R profclems/glab”
Built with ❤ by Clement Sam <https://clementsam.tech>`)

}
112 changes: 110 additions & 2 deletions cmd/glab/utils/issue.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,118 @@
package utils

import "fmt"
import (
"fmt"
"os"
"text/tabwriter"
)

// PrintHelpIssue : display issue command help
func PrintHelpIssue() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("USAGE")
fmt.Println(" glab issue <subcommand> [flags]")
fmt.Println()
fmt.Println("SUBCOMMANDS")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "create", "Create an issue")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "list, ls", "List issues")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "delete", "Delete an issue")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "subscribe", "Subscribe to an issue")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "unsubscribe", "Unsubscribe from an issue")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "open", "Open an issue")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "reopen", "Reopen an issue")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "close", "Close an issue")
}

// PrintHelpIssueCreate : display issue create command help
func PrintHelpIssueCreate() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("Create an issue")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue create [flags]")
fmt.Println()
fmt.Println("FLAGS")
fmt.Fprintf(tabWriter, " %s\t%s\n", "--title", `Supply a title. Otherwise, you will be prompted for one. (--title="string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--description", `Supply a description. Otherwise, you will be prompted for one. (--description="string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--label", `Add label by name. Multiple labels should be comma-separated. Otherwise, you will be prompted for one, though optional (--label="string,string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--assigns", `Assign issue to people by their ID. Multiple values should be comma separated (--assigns=value,value)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--milestone", `Add the issue to a milestone by ID. (--milestone=value)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--confidential", `Set issue as confidential. Optional boolean value (--confidential) or (--confidential=true)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--mr, --resolved-by-merge-request", `Link issue to a merge request by ID. (--mr=id)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--weight", `Set weight of issue`)
}

// PrintHelpIssueList : display issue list command help
func PrintHelpIssueList() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println(`List issues`)
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue list [flags]")
fmt.Println(" glab issue ls [flags]")
fmt.Println()
fmt.Println("FLAGS")
fmt.Fprintf(tabWriter, " %s\t%s\n", "--opened", `Get all opened issues (default)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--all", `Show all opened and closed issues`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--closed", `Get the list of closed issues`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--label, --labels", `Search by label name. Multiple labels should be comma-separated. Otherwise, you will be prompted for one, though optional (--label="string,string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--milestone", `Search for issues from a milestone by milestone ID. (--milestone=value)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--confidential", `Search for confidential issues. Optional boolean value (--confidential) or (--confidential=true)`)
}

// PrintHelpIssueDelete : display issue delete command help
func PrintHelpIssueDelete() {
fmt.Println(`Delete issues`)
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue delete <id>")
fmt.Println(" glab issue delete <comma,separated,ids>")
}

fmt.Println(`Issue Help`)
// PrintHelpIssueSubscribe : display issue subscribe command help
func PrintHelpIssueSubscribe() {
fmt.Println(`Subscribe to issues`)
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue subscribe <id>")
fmt.Println(" glab issue subscribe <comma,separated,ids>")
}

// PrintHelpIssueUnsubscribe : display issue unsubscribe command help
func PrintHelpIssueUnsubscribe() {
fmt.Println(`Unsubscribe from issues`)
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue unsubscribe <id>")
fmt.Println(" glab issue unsubscribe <comma,separated,ids>")
}

// PrintHelpIssueOpen : display issue open command help
func PrintHelpIssueOpen() {
fmt.Println(`Reopen issues`)
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue open <id>")
fmt.Println(" glab issue open <comma,separated,ids>")
}

// PrintHelpIssueReopen : display issue reopen command help
func PrintHelpIssueReopen() {
fmt.Println(`Reopen issues`)
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue reopen <id>")
fmt.Println(" glab issue reopen <comma,separated,ids>")
}

// PrintHelpIssueClose : display issue close command help
func PrintHelpIssueClose() {
fmt.Println(`Close issues`)
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab issue close <id>")
fmt.Println(" glab issue close <comma,separated,ids>")
}
171 changes: 169 additions & 2 deletions cmd/glab/utils/mr.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,177 @@
package utils

import "fmt"
import (
"fmt"
"os"
"text/tabwriter"
)

// PrintHelpMr : display merge request help
func PrintHelpMr() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("USAGE")
fmt.Println(" glab mr <subcommand> [flags]")
fmt.Println()
fmt.Println("SUBCOMMANDS")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "create", "Create a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "merge, accept", "Merge a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "list, ls", "List merge requests")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "close", "Close a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "reopen", "Reopen a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "delete", "Delete a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "subscribe", "Subscribe to a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "unsubscribe", "Unsubscribe from a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "issues", "List the issues that will close when the merge request is accepted")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "approve", "Approve a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "revoke", "Unapprove a merge request")
fmt.Fprintf(tabWriter, " %s:\t%s\n", "Update", "Update an existing merge request")
}

// PrintHelpMrCreate : display merge request create help
func PrintHelpMrCreate() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("Create a merge request")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr create [flags]")
fmt.Println()
fmt.Println("FLAGS")
fmt.Fprintf(tabWriter, " %s\t%s\n", "--title", `Supply a title. Otherwise, you will be prompted for one. (--title="string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--description", `Supply a description. Otherwise, you will be prompted for one. (--description="string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--source", `Supply the source branch. Otherwise, you will be prompted for one. (--source="string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--target", `Supply the target branch. Otherwise, you will be prompted for one. (--target="string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--label", `Add label by name. Multiple labels should be comma separated. Otherwise, you will be prompted for one, though optional (--label="string,string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--assigns", `Assign merge request to people by their ID. Multiple values should be comma separated (--assigns=value,value)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--milestone", `Add the merge request to a milestone by ID. (--milestone=value)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--allow-collaboration", `Allow commits from members who can merge to the target branch. Optional boolean value (--allow-collaboration) or (--allow-collaboration=true)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--remove-source-branch", `removes the source branch when merged. Optional boolean value (--remove-source-branch) or (--remove-source-branch=true)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--target-project", `The target project ID`)
}

// PrintHelpMrList : display merge request list help
func PrintHelpMrList() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("List merge requests")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr list [flags]")
fmt.Println(" glab mr ls [flags]")
fmt.Println()
fmt.Println("FLAGS")
fmt.Fprintf(tabWriter, " %s\t%s\n", "--opened", `Get all opened merge requests (default)`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--all", `Show all opened and closed merge requests`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--closed", `Get the list of closed merge requests`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--label, --labels", `Search for merge requests by label. Multiple labels should be comma separated. Otherwise, you will be prompted for one, though optional (--labels="string,string")`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--milestone", `Search for merge requests by milestone ID. (--milestone=value)`)
}

// PrintHelpMrDelete : display merge request delete help
func PrintHelpMrDelete() {
fmt.Println("Delete merge requests")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr delete <ID>")
fmt.Println(" glab mr delete <comma,separated,IDs>")
}

// PrintHelpMrSubscribe : display merge request subscribe help
func PrintHelpMrSubscribe() {
fmt.Println("Subscribe to merge requests")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr subscribe <ID>")
fmt.Println(" glab mr subscribe <comma,separated,IDs>")
}

// PrintHelpMrUnsubscribe : display merge request unsubscribe help
func PrintHelpMrUnsubscribe() {
fmt.Println("Unsubscribe from merge requests")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr unsubscribe <ID>")
fmt.Println(" glab mr unsubscribe <comma,separated,IDs>")
}

fmt.Println(`Merge Request Help`)
// PrintHelpMrAccept : display merge request accept help
func PrintHelpMrAccept() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("Accept a merge request")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr accept <ID>")
fmt.Println(" glab mr merge <ID>")
fmt.Println()
fmt.Println("FLAGS")
fmt.Fprintf(tabWriter, " %s\t%s\n", "--message", `Custom merge commit message`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--squash-message", `Custom squash commit message`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--squash", `Squashes the commits into a single commit on merge`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--remove-source-branch", `Removes the source branch`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--when-pipeline-succeed", `Merges when the pipeline succeeds`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--sha", `If present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail`)
}

// PrintHelpMrClose : display merge request close help
func PrintHelpMrClose() {
fmt.Println("Close a merge request")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr close <ID>")
fmt.Println(" glab mr close <comma,separated,IDs>")
}

// PrintHelpMrReopen : display merge request reopen help
func PrintHelpMrReopen() {
fmt.Println("Reopen a merge request")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr reopen <ID>")
fmt.Println(" glab mr reopen <comma,separated,IDs>")
}

// PrintHelpMrIssues : display merge request issues help
func PrintHelpMrIssues() {
fmt.Println("List the issues that will close when the merge request is accepted")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr issues <ID>")
}

// PrintHelpMrApprove : display merge request approve help
func PrintHelpMrApprove() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("Approve a merge request")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr approve <ID>")
fmt.Println()
fmt.Println("FLAGS")
fmt.Fprintf(tabWriter, " %s\t%s\n", "--sha", `The HEAD of the merge request`)
}

// PrintHelpMrRevoke : display merge request revoke help
func PrintHelpMrRevoke() {
fmt.Println("Unapprove a merge request")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr revoke <ID>")
}

// PrintHelpMrUpdate : display merge request update help
func PrintHelpMrUpdate() {
tabWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 2, '\t', 0)
defer tabWriter.Flush()
fmt.Println("Update an existing merge request")
fmt.Println()
fmt.Println("USAGE")
fmt.Println(" glab mr update <ID>")
fmt.Println()
fmt.Println("FLAGS")
fmt.Fprintf(tabWriter, " %s\t%s\n", "--title", `Update the title of the merge request`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--description", `Update the description of the merge request`)
fmt.Fprintf(tabWriter, " %s\t%s\n", "--lock-discussion", `Boolean to set if the discussion should be locked.`)
}
Loading

0 comments on commit ea8ad25

Please sign in to comment.