-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathtroubleshoot.go
More file actions
50 lines (41 loc) · 1.15 KB
/
troubleshoot.go
File metadata and controls
50 lines (41 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cmd
import (
"fmt"
"net/http"
"time"
"github.com/exercism/cli/cli"
"github.com/exercism/cli/config"
"github.com/spf13/cobra"
)
// fullAPIKey flag for troubleshoot command.
var fullAPIKey bool
// troubleshootCmd does a diagnostic self-check.
var troubleshootCmd = &cobra.Command{
Use: "troubleshoot",
Aliases: []string{"t"},
Short: "Troubleshoot does a diagnostic self-check.",
Long: `Provides output to help with troubleshooting.
If you're running into trouble, copy and paste the output from the troubleshoot
command into a GitHub issue so we can help figure out what's going on.
`,
RunE: func(cmd *cobra.Command, args []string) error {
cli.HTTPClient = &http.Client{Timeout: 20 * time.Second}
c := cli.New(Version)
cfg, err := config.NewUserConfig()
if err != nil {
return err
}
status := cli.NewStatus(c, *cfg)
status.Censor = !fullAPIKey
s, err := status.Check()
if err != nil {
return err
}
fmt.Printf("%s", s)
return nil
},
}
func init() {
RootCmd.AddCommand(troubleshootCmd)
troubleshootCmd.Flags().BoolVarP(&fullAPIKey, "full-api-key", "f", false, "display the user's full API key, censored by default")
}