To make "ghcs" importable, this separates out the `main()` function into its own package that lives under "cmd/ghcs/main". Typically the main package would be called "cmd/ghcs", but we wanted to leave the current ghcs implementation where it is to avoid causing conflicts with current work in progress. Co-authored-by: Jose Garcia <josebalius@github.com>
26 lines
580 B
Go
26 lines
580 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/github/ghcs/cmd/ghcs"
|
|
)
|
|
|
|
func main() {
|
|
rootCmd := ghcs.NewRootCmd()
|
|
if err := rootCmd.Execute(); err != nil {
|
|
explainError(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func explainError(w io.Writer, err error) {
|
|
if errors.Is(err, ghcs.ErrTokenMissing) {
|
|
fmt.Fprintln(w, "The GITHUB_TOKEN environment variable is required. Create a Personal Access Token at https://github.com/settings/tokens/new?scopes=repo")
|
|
fmt.Fprintln(w, "Make sure to enable SSO for your organizations after creating the token.")
|
|
return
|
|
}
|
|
}
|