-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.go
More file actions
31 lines (25 loc) · 1.21 KB
/
command.go
File metadata and controls
31 lines (25 loc) · 1.21 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
package porter
// =============================================================================
// COMMAND EXECUTION
// =============================================================================
// Run executes a shell command on the remote server.
func Run(cmd string) TaskBuilder {
return TaskBuilder{Task{Action: "run", Body: cmd, Name: "Run: " + cmd}}
}
// Pause waits for the specified duration (e.g., "5s", "1m").
func Pause(duration string) TaskBuilder {
return TaskBuilder{Task{Action: "pause", Body: duration, Name: "Wait " + duration}}
}
// =============================================================================
// OUTPUT CAPTURE
// =============================================================================
// Capture executes a command and stores its output in a variable.
// Use .Register("varname") to specify the variable name.
func Capture(cmd string) TaskBuilder {
return TaskBuilder{Task{Action: "capture", Body: cmd, Name: "Capture: " + cmd}}
}
// CaptureSudo executes a command with sudo and stores its output.
// Use .Register("varname") to specify the variable name.
func CaptureSudo(cmd string) TaskBuilder {
return TaskBuilder{Task{Action: "capture_sudo", Body: cmd, Name: "Capture: " + cmd}}
}