-
Notifications
You must be signed in to change notification settings - Fork 232
/
disabled.go
47 lines (39 loc) · 1.07 KB
/
disabled.go
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
package cmd
import (
"fmt"
"github.com/CircleCI-Public/circleci-cli/settings"
"github.com/CircleCI-Public/circleci-cli/version"
"github.com/spf13/cobra"
)
type disableOptions struct {
cfg *settings.Config
command string
args []string
}
// nolint: unparam
func newDisabledCommand(config *settings.Config, command string) *cobra.Command {
opts := disableOptions{
cfg: config,
command: command,
}
disable := &cobra.Command{
Use: opts.command,
Short: "This command is unavailable on your platform",
PersistentPreRun: func(_ *cobra.Command, _ []string) {
opts.cfg.SkipUpdateCheck = true
},
PreRun: func(cmd *cobra.Command, args []string) {
opts.args = args
},
Run: func(_ *cobra.Command, _ []string) {
disableCommand(opts)
},
}
return disable
}
func disableCommand(opts disableOptions) {
fmt.Printf("`%s` is not available because this tool was installed using `%s`.\n", opts.command, version.PackageManager())
if opts.command == "update" {
fmt.Println("Please consult the package manager's documentation on how to update the CLI.")
}
}