-
Notifications
You must be signed in to change notification settings - Fork 13
/
clean.go
113 lines (107 loc) · 3.22 KB
/
clean.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package cmdtree
import (
"github.com/ActiveState/cli/internal/captain"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/runners/clean"
)
func newCleanCommand(prime *primer.Values) *captain.Command {
return captain.NewCommand(
"clean",
locale.Tl("clean_title", "Cleaning Resources"),
locale.T("clean_description"),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(ccmd *captain.Command, _ []string) error {
prime.Output().Print(ccmd.Help())
return nil
},
).SetGroup(UtilsGroup).SetSupportsStructuredOutput()
}
func newCleanUninstallCommand(prime *primer.Values, globals *globalOptions) *captain.Command {
params := clean.UninstallParams{}
return captain.NewCommand(
"uninstall",
locale.Tl("clean_uninstall_title", "Uninstalling"),
locale.T("uninstall_description"),
prime,
[]*captain.Flag{
{
Name: "all",
Shorthand: "a",
Description: locale.Tl("flag_state_clean_uninstall_all", "Also delete all associated config and cache files"),
Value: ¶ms.All,
},
{
Name: "force",
Shorthand: "f",
Description: locale.T("flag_state_clean_uninstall_force_description"),
Value: ¶ms.Force,
},
{
// This option is only used by the Windows uninstall shortcut to ask the user if they wish
// to delete everything or keep cache and config. The user is also asked to press Enter
// after the uninstall process is scheduled so they may note the printed log file path.
Name: "prompt",
Description: "Asks the user if everything should be deleted or to keep cache and config",
Hidden: true, // this is not a user-facing flag
Value: ¶ms.Prompt,
},
},
[]*captain.Argument{},
func(ccmd *captain.Command, _ []string) error {
runner, err := clean.NewUninstall(prime)
if err != nil {
return err
}
params.NonInteractive = globals.NonInteractive // distinct from --force
return runner.Run(¶ms)
},
)
}
func newCleanCacheCommand(prime *primer.Values, globals *globalOptions) *captain.Command {
runner := clean.NewCache(prime)
params := clean.CacheParams{}
return captain.NewCommand(
"cache",
locale.Tl("clean_cache_title", "Cleaning Cached Runtimes"),
locale.T("cache_description"),
prime,
[]*captain.Flag{},
[]*captain.Argument{
{
Name: "org/project",
Description: locale.T("arg_state_clean_cache_project_description"),
Required: false,
Value: ¶ms.Project,
},
},
func(ccmd *captain.Command, _ []string) error {
params.Force = globals.NonInteractive
return runner.Run(¶ms)
},
)
}
func newCleanConfigCommand(prime *primer.Values) *captain.Command {
runner := clean.NewConfig(prime)
params := clean.ConfigParams{}
return captain.NewCommand(
"config",
locale.Tl("clean_config_title", "Cleaning Configuration"),
locale.T("clean_config_description"),
prime,
[]*captain.Flag{
{
Name: "force",
Shorthand: "f",
Description: locale.T("flag_state_clean_config_force_description"),
Value: ¶ms.Force,
},
},
[]*captain.Argument{},
func(ccmd *captain.Command, _ []string) error {
return runner.Run(¶ms)
},
)
}