-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.go
More file actions
135 lines (106 loc) · 3.13 KB
/
cli.go
File metadata and controls
135 lines (106 loc) · 3.13 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package main
import "errors"
type CLI struct {
Init InitCmd `cmd:"" help:"Shell integration (eval in .zshrc or .bashrc)."`
Set SetCmd `cmd:"" help:"Set an environment variable."`
Unset UnsetCmd `cmd:"" help:"Unset an environment variable."`
List ListCmd `cmd:"" help:"Show all variables and current values."`
Aliases AliasesCmd `cmd:"" help:"Show alias → variable mappings."`
Path PathCmd `cmd:"" help:"Print the vex bin directory path."`
Bin BinCmd `cmd:"" help:"Manage curated standalone binaries."`
}
type InitCmd struct{}
func (c *InitCmd) Run() error {
cmdInit()
return nil
}
type SetCmd struct {
Alias string `arg:"" name:"alias" help:"Alias to set."`
Value string `arg:"" name:"value" help:"Value to assign." passthrough:"all"`
}
func (c *SetCmd) Run() error {
cmdSet(c.Alias, c.Value)
return nil
}
type UnsetCmd struct {
Alias string `arg:"" name:"alias" help:"Alias to unset."`
}
func (c *UnsetCmd) Run() error {
cmdUnset(c.Alias)
return nil
}
type ListCmd struct{}
func (c *ListCmd) Run() error {
cmdList()
return nil
}
type AliasesCmd struct{}
func (c *AliasesCmd) Run() error {
cmdAliases()
return nil
}
type PathCmd struct{}
func (c *PathCmd) Run() error {
cmdPath()
return nil
}
type BinCmd struct {
Install BinInstallCmd `cmd:"" help:"Install a curated standalone binary."`
Ls BinLsCmd `cmd:"" help:"List curated managed binaries."`
Status BinStatusCmd `cmd:"" help:"Show install and update status."`
Sync BinSyncCmd `cmd:"" help:"Install missing and update outdated binaries."`
Update BinUpdateCmd `cmd:"" help:"Update one or all managed binaries."`
Version BinVersionCmd `cmd:"" help:"Show installed and latest version."`
}
func (c *BinCmd) Help() string {
return "Only binaries hardcoded into vex are supported."
}
type BinInstallCmd struct {
Tool string `arg:"" name:"tool" help:"Managed tool to install."`
Force bool `help:"Overwrite an existing installation or take over an unmanaged binary."`
}
func (c *BinInstallCmd) Run() error {
cmdBinInstall(c.Tool, c.Force)
return nil
}
type BinLsCmd struct{}
func (c *BinLsCmd) Run() error {
cmdBinLs()
return nil
}
type BinStatusCmd struct {
Tool string `arg:"" name:"tool" help:"Managed tool to inspect."`
}
func (c *BinStatusCmd) Run() error {
cmdBinStatus(c.Tool)
return nil
}
type BinSyncCmd struct {
DryRun bool `help:"Show what would change without installing or updating binaries."`
}
func (c *BinSyncCmd) Run() error {
cmdBinSync(c.DryRun)
return nil
}
type BinUpdateCmd struct {
Tool string `arg:"" name:"tool" optional:"" help:"Managed tool to update."`
All bool `help:"Update all managed binaries."`
Force bool `help:"Reinstall even when the latest version is already installed."`
}
func (c *BinUpdateCmd) Validate() error {
if c.All == (c.Tool == "") {
return errors.New("specify either <tool> or --all")
}
return nil
}
func (c *BinUpdateCmd) Run() error {
cmdBinUpdate(c.Tool, c.All, c.Force)
return nil
}
type BinVersionCmd struct {
Tool string `arg:"" name:"tool" help:"Managed tool to compare."`
}
func (c *BinVersionCmd) Run() error {
cmdBinVersion(c.Tool)
return nil
}