-
Notifications
You must be signed in to change notification settings - Fork 5
/
command_suspend.go
41 lines (36 loc) · 1.08 KB
/
command_suspend.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
package vagrant
// SuspendCommand specifies options and output from vagrant suspend
type SuspendCommand struct {
BaseCommand
MachineNameArgument
ErrorResponse
}
// Suspend will cause the vagrant machine to "suspend", like putting a computer
// to sleep. After setting options as appropriate, you must call Run() or
// Start() followed by Wait() to execute. Errors will be recorded in Error.
func (client *VagrantClient) Suspend() *SuspendCommand {
return &SuspendCommand{
BaseCommand: newBaseCommand(client),
ErrorResponse: newErrorResponse(),
}
}
func (cmd *SuspendCommand) init() error {
if cmd.MachineName != "" {
return cmd.BaseCommand.init(&cmd.ErrorResponse, "suspend", cmd.MachineName)
}
return cmd.BaseCommand.init(&cmd.ErrorResponse, "suspend")
}
// Run the command
func (cmd *SuspendCommand) 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 *SuspendCommand) Start() error {
if err := cmd.init(); err != nil {
return err
}
return cmd.BaseCommand.Start()
}