-
Notifications
You must be signed in to change notification settings - Fork 85
/
runtime.go
43 lines (37 loc) · 1.83 KB
/
runtime.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
package cliflags
import "github.com/spf13/pflag"
func DefaultRunTimeSettings() *RunTimeSettings {
return &RunTimeSettings{
WaitForJobToFinish: true,
WaitForJobTimeoutSecs: DefaultRunWaitSeconds,
PrintJobIDOnly: false,
Follow: false,
DryRun: false,
}
}
type RunTimeSettings struct {
WaitForJobToFinish bool // Wait for the job to finish before returning
WaitForJobTimeoutSecs int // Timeout for waiting for the job to finish
PrintJobIDOnly bool // Only print the Job ID as output
PrintNodeDetails bool
Follow bool // Follow along with the output of the job
DryRun bool // iff true do not submit the job, but instead print out what will be submitted.
}
const DefaultRunWaitSeconds = 600
func NewRunTimeSettingsFlags(settings *RunTimeSettings) *pflag.FlagSet {
flags := pflag.NewFlagSet("Runtime settings", pflag.ContinueOnError)
flags.BoolVar(&settings.WaitForJobToFinish, "wait", settings.WaitForJobToFinish,
`Wait for the job to finish. Use --wait=false to return as soon as the job is submitted.`)
flags.IntVar(&settings.WaitForJobTimeoutSecs, "wait-timeout-secs", settings.WaitForJobTimeoutSecs,
`When using --wait, how many seconds to wait for the job to complete before giving up.`)
flags.BoolVar(&settings.PrintJobIDOnly, "id-only", settings.PrintJobIDOnly,
`Print out only the Job ID on successful submission.`)
flags.BoolVar(&settings.PrintNodeDetails, "node-details", settings.PrintNodeDetails,
`Print out details of all nodes (overridden by --id-only).`)
flags.BoolVarP(&settings.Follow, "follow", "f", settings.Follow,
`When specified will follow the output from the job as it runs`)
flags.BoolVar(
&settings.DryRun, "dry-run", settings.DryRun,
`Do not submit the job, but instead print out what will be submitted`)
return flags
}