-
Notifications
You must be signed in to change notification settings - Fork 5
/
command_global_status.go
50 lines (43 loc) · 1.29 KB
/
command_global_status.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
package vagrant
// GlobalStatusCommand specifies options and output from vagrant global-status
type GlobalStatusCommand struct {
BaseCommand
GlobalStatusResponse
// Prune will remove invalid entries.
Prune bool
}
// GlobalStatus will return the status of all vagrant machines regardless of
// directory. After setting options as appropriate, you must call Run() or
// Start() followed by Wait() to execute. Output will be in Status and any
// error will be in Error.
func (client *VagrantClient) GlobalStatus() *GlobalStatusCommand {
return &GlobalStatusCommand{
BaseCommand: newBaseCommand(client),
GlobalStatusResponse: newGlobalStatusResponse(),
}
}
func (cmd *GlobalStatusCommand) buildArguments() []string {
args := []string{}
if cmd.Prune {
args = append(args, "--prune")
}
return args
}
func (cmd *GlobalStatusCommand) init() error {
args := cmd.buildArguments()
return cmd.BaseCommand.init(&cmd.GlobalStatusResponse, "global-status", args...)
}
// Run the command
func (cmd *GlobalStatusCommand) Run() error {
if err := cmd.Start(); err != nil {
return err
}
return cmd.Wait()
}
// Start the command. You must call Wait() to complete execution.
func (cmd *GlobalStatusCommand) Start() error {
if err := cmd.init(); err != nil {
return err
}
return cmd.BaseCommand.Start()
}