diff --git a/cmd/check/main.go b/cmd/check/main.go index da3866e..131a045 100644 --- a/cmd/check/main.go +++ b/cmd/check/main.go @@ -2,6 +2,7 @@ package main import ( + "flag" "fmt" "log" "os" @@ -23,9 +24,33 @@ func main() { fmt.Printf("Found %d people\n", len(people)) } +var helpFlag bool + func init() { log.SetFlags(log.Ldate | log.Ltime | log.LUTC) + flag.BoolVar(&helpFlag, "help", false, "Show this help message") + flag.BoolVar(&helpFlag, "h", false, "Show this help message") + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), `check - validate ShiftStack team member configuration + +Parses the PEOPLE environment variable and reports the number of team members +found, exiting with an error if the data is syntactically incorrect. + +Environment variables: + PEOPLE JSON-formatted team member information + +Flags: +`) + flag.PrintDefaults() + } + flag.Parse() + + if helpFlag { + flag.Usage() + os.Exit(0) + } + ex_usage := false if PEOPLE == "" { ex_usage = true diff --git a/cmd/doctext/main.go b/cmd/doctext/main.go index 4ebceb4..b6cef96 100644 --- a/cmd/doctext/main.go +++ b/cmd/doctext/main.go @@ -2,6 +2,8 @@ package main import ( "context" + "flag" + "fmt" "log" "os" "strings" @@ -106,7 +108,35 @@ func main() { } } +var helpFlag bool + func init() { + flag.BoolVar(&helpFlag, "help", false, "Show this help message") + flag.BoolVar(&helpFlag, "h", false, "Show this help message") + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), `doctext - notify assignees about missing release note text + +Finds ShiftStack Jira bugs in late-stage statuses (Release Pending, Verified, +ON_QA) that are missing release note text and sends Slack notifications to +their assignees. + +Environment variables: + SLACK_HOOK Slack webhook URL for notifications + JIRA_EMAIL Jira account email address + JIRA_TOKEN Jira API token + PEOPLE JSON-formatted team member information + +Flags: +`) + flag.PrintDefaults() + } + flag.Parse() + + if helpFlag { + flag.Usage() + os.Exit(0) + } + ex_usage := false if SLACK_HOOK == "" { ex_usage = true diff --git a/cmd/posttriage/main.go b/cmd/posttriage/main.go index 66bd4f0..c80d1ce 100644 --- a/cmd/posttriage/main.go +++ b/cmd/posttriage/main.go @@ -2,6 +2,8 @@ package main import ( "context" + "flag" + "fmt" "log" "os" "strings" @@ -80,7 +82,32 @@ func main() { } } +var helpFlag bool + func init() { + flag.BoolVar(&helpFlag, "help", false, "Show this help message") + flag.BoolVar(&helpFlag, "h", false, "Show this help message") + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), `posttriage - audit triaged ShiftStack Jira bugs + +Checks all bugs labelled "Triaged" and removes the label from any that no +longer meet triage criteria (e.g. missing priority or release blocker status). + +Environment variables: + JIRA_EMAIL Jira account email address + JIRA_TOKEN Jira API token + +Flags: +`) + flag.PrintDefaults() + } + flag.Parse() + + if helpFlag { + flag.Usage() + os.Exit(0) + } + if JIRA_EMAIL == "" { log.Print("FATAL: Required environment variable not found: JIRA_EMAIL") os.Exit(64) diff --git a/cmd/pretriage/main.go b/cmd/pretriage/main.go index 7a7335b..16bea85 100644 --- a/cmd/pretriage/main.go +++ b/cmd/pretriage/main.go @@ -2,6 +2,8 @@ package main import ( "context" + "flag" + "fmt" "log" "math/rand" "os" @@ -200,9 +202,37 @@ func main() { } } +var helpFlag bool + func init() { log.SetFlags(log.Ldate | log.Ltime | log.LUTC) + flag.BoolVar(&helpFlag, "help", false, "Show this help message") + flag.BoolVar(&helpFlag, "h", false, "Show this help message") + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), `pretriage - pre-triage ShiftStack Jira bugs + +Pre-sets required fields for ART reconciliation bugs, assigns untriaged bugs +to available team members, and sends Slack notifications for each assignment. + +Environment variables: + SLACK_HOOK Slack webhook URL for notifications + JIRA_EMAIL Jira account email address + JIRA_TOKEN Jira API token + JIRA_ACCOUNT_ID Jira account ID used to identify self-assigned bugs + PEOPLE JSON-formatted team member information + +Flags: +`) + flag.PrintDefaults() + } + flag.Parse() + + if helpFlag { + flag.Usage() + os.Exit(0) + } + queryUntriaged = query.ShiftStack + `AND ( assignee is EMPTY OR assignee = "` + JIRA_ACCOUNT_ID + `" ) AND (labels not in ("Triaged") OR labels is EMPTY)` ex_usage := false diff --git a/cmd/triage/main.go b/cmd/triage/main.go index 0967048..e2bb41b 100644 --- a/cmd/triage/main.go +++ b/cmd/triage/main.go @@ -2,6 +2,8 @@ package main import ( "context" + "flag" + "fmt" "log" "os" "strings" @@ -92,7 +94,34 @@ func main() { } } +var helpFlag bool + func init() { + flag.BoolVar(&helpFlag, "help", false, "Show this help message") + flag.BoolVar(&helpFlag, "h", false, "Show this help message") + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), `triage - triage ShiftStack Jira bugs + +Assigns untriaged ShiftStack Jira bugs to available team members and sends +Slack notifications for each assignment. + +Environment variables: + SLACK_HOOK Slack webhook URL for notifications + JIRA_EMAIL Jira account email address + JIRA_TOKEN Jira API token + PEOPLE JSON-formatted team member information + +Flags: +`) + flag.PrintDefaults() + } + flag.Parse() + + if helpFlag { + flag.Usage() + os.Exit(0) + } + ex_usage := false if SLACK_HOOK == "" { ex_usage = true