-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjob.go
106 lines (92 loc) · 2.16 KB
/
job.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package main
import (
"fmt"
"github.com/codegangsta/cli"
"github.com/paulhamby/rundeck-client/cmd"
"os"
"strings"
)
var jobCommands = cli.Command{
Name: "job",
Usage: "job commands",
Subcommands: []cli.Command{
{
Name: "list",
Usage: "List Jobs: rundeck-client job list ",
Before: ensureProject,
Action: func(c *cli.Context) {
projectid := c.GlobalString("project")
cmd.ListJobs(projectid)
},
},
{
Name: "get",
Usage: "Get Job: rundeck-client job get jobid",
Action: func(c *cli.Context) {
var jobid string
if len(c.Args()) != 1 {
fmt.Printf("Usage: rundeck-client job get jobid\n")
os.Exit(1)
} else {
jobid = c.Args()[0]
}
cmd.GetJob(jobid)
},
},
{
Name: "find",
Usage: "Find Job By Name: rundeck-client job find name",
Before: ensureProject,
Action: func(c *cli.Context) {
var jobid string
if len(c.Args()) != 1 {
fmt.Printf("Usage: rundeck-client job find\n")
os.Exit(1)
} else {
jobid = c.Args()[0]
}
projectid := c.GlobalString("project")
cmd.FindJobByName(jobid, projectid)
},
},
{
Name: "options",
Usage: "Get Job Options: rundeck-client job options job project",
Before: ensureProject,
Action: func(c *cli.Context) {
var job string
if len(c.Args()) != 1 {
fmt.Printf("Get Job Options: rundeck-client job options job \n")
os.Exit(1)
} else {
job = c.Args()[0]
}
projectid := c.GlobalString("project")
cmd.GetJobOptions(job, projectid)
},
},
{
Name: "run",
Usage: "Run Job: rundeck-client job run job option1=option,option2=option",
Before: ensureProject,
Action: func(c *cli.Context) {
var options string
args := c.Args()
nbrArgsPassed := len(args)
if nbrArgsPassed < 1 {
fmt.Printf("Run Job: rundeck-client job run job option1=option,option2=option\n")
os.Exit(1)
} else {
s := 1
for s < nbrArgsPassed {
options = options + args[s] + " "
s++
}
options = strings.TrimSpace(options)
}
projectid := c.GlobalString("project")
cmd.RunJob(projectid, args[0], options)
},
},
},
}