-
Notifications
You must be signed in to change notification settings - Fork 5
/
command_halt.go
50 lines (43 loc) · 1.15 KB
/
command_halt.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
// A HaltCommand specifies the options and output of vagrant halt.
type HaltCommand struct {
BaseCommand
ErrorResponse
// Force shutdown (equivalent to pulling the power from the machine, default:
// false)
Force bool
}
// Run vagrant halt. 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) Halt() *HaltCommand {
return &HaltCommand{
BaseCommand: newBaseCommand(client),
ErrorResponse: newErrorResponse(),
}
}
func (cmd *HaltCommand) buildArguments() []string {
args := []string{}
if cmd.Force {
args = append(args, "--force")
}
return args
}
func (cmd *HaltCommand) init() error {
args := cmd.buildArguments()
return cmd.BaseCommand.init(&cmd.ErrorResponse, "halt", args...)
}
// Run the command
func (cmd *HaltCommand) Run() error {
if err := cmd.init(); err != nil {
return err
}
return cmd.BaseCommand.Run()
}
// Start the command. You must call Wait() to complete execution.
func (cmd *HaltCommand) Start() error {
if err := cmd.init(); err != nil {
return err
}
return cmd.BaseCommand.Start()
}