-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f12f74e
commit 3c26d22
Showing
10 changed files
with
208 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
package build | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/template" | ||
|
||
"github.com/drone/drone-cli/drone/internal" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var buildQueueCmd = cli.Command{ | ||
Name: "queue", | ||
Usage: "show build queue", | ||
ArgsUsage: " ", | ||
Action: buildQueue, | ||
Flags: []cli.Flag{ | ||
cli.StringFlag{ | ||
Name: "format", | ||
Usage: "format output", | ||
Value: tmplBuildQueue, | ||
}, | ||
}, | ||
} | ||
|
||
func buildQueue(c *cli.Context) error { | ||
|
||
client, err := internal.NewClient(c) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
builds, err := client.BuildQueue() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(builds) == 0 { | ||
fmt.Println("there are no pending or running builds") | ||
return nil | ||
} | ||
|
||
tmpl, err := template.New("_").Parse(c.String("format") + "\n") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, build := range builds { | ||
tmpl.Execute(os.Stdout, build) | ||
} | ||
return nil | ||
} | ||
|
||
// template for build list information | ||
var tmplBuildQueue = "\x1b[33m{{ .FullName }} #{{ .Number }} \x1b[0m" + ` | ||
Status: {{ .Status }} | ||
Event: {{ .Event }} | ||
Commit: {{ .Commit }} | ||
Branch: {{ .Branch }} | ||
Ref: {{ .Ref }} | ||
Author: {{ .Author }} {{ if .AuthorEmail }}<{{.AuthorEmail}}>{{ end }} | ||
Message: {{ .Message }} | ||
` | ||
// import ( | ||
// "fmt" | ||
// "os" | ||
// "text/template" | ||
|
||
// "github.com/drone/drone-cli/drone/internal" | ||
// "github.com/urfave/cli" | ||
// ) | ||
|
||
// var buildQueueCmd = cli.Command{ | ||
// Name: "queue", | ||
// Usage: "show build queue", | ||
// ArgsUsage: " ", | ||
// Action: buildQueue, | ||
// Flags: []cli.Flag{ | ||
// cli.StringFlag{ | ||
// Name: "format", | ||
// Usage: "format output", | ||
// Value: tmplBuildQueue, | ||
// }, | ||
// }, | ||
// } | ||
|
||
// func buildQueue(c *cli.Context) error { | ||
|
||
// client, err := internal.NewClient(c) | ||
// if err != nil { | ||
// return err | ||
// } | ||
|
||
// builds, err := client.BuildQueue() | ||
// if err != nil { | ||
// return err | ||
// } | ||
|
||
// if len(builds) == 0 { | ||
// fmt.Println("there are no pending or running builds") | ||
// return nil | ||
// } | ||
|
||
// tmpl, err := template.New("_").Parse(c.String("format") + "\n") | ||
// if err != nil { | ||
// return err | ||
// } | ||
|
||
// for _, build := range builds { | ||
// tmpl.Execute(os.Stdout, build) | ||
// } | ||
// return nil | ||
// } | ||
|
||
// // template for build list information | ||
// var tmplBuildQueue = "\x1b[33m{{ .FullName }} #{{ .Number }} \x1b[0m" + ` | ||
// Status: {{ .Status }} | ||
// Event: {{ .Event }} | ||
// Commit: {{ .Commit }} | ||
// Branch: {{ .Branch }} | ||
// Ref: {{ .Ref }} | ||
// Author: {{ .Author }} {{ if .AuthorEmail }}<{{.AuthorEmail}}>{{ end }} | ||
// Message: {{ .Message }} | ||
// ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package queue | ||
|
||
import "github.com/urfave/cli" | ||
|
||
// Command exports the queue command set. | ||
var Command = cli.Command{ | ||
Name: "queue", | ||
Usage: "queue operations", | ||
Subcommands: []cli.Command{ | ||
queueListCmd, | ||
queuePauseCmd, | ||
queueResumeCmd, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package queue | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/template" | ||
|
||
"github.com/drone/drone-cli/drone/internal" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var queueListCmd = cli.Command{ | ||
Name: "ls", | ||
Usage: "list queue items", | ||
Action: queueList, | ||
Flags: []cli.Flag{ | ||
cli.StringFlag{ | ||
Name: "format", | ||
Usage: "format output", | ||
Value: tmplStage, | ||
}, | ||
}, | ||
} | ||
|
||
func queueList(c *cli.Context) (err error) { | ||
client, err := internal.NewClient(c) | ||
if err != nil { | ||
return err | ||
} | ||
builds, err := client.Queue() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(builds) == 0 { | ||
fmt.Println("there are no pending or running builds") | ||
return nil | ||
} | ||
|
||
tmpl, err := template.New("_").Parse(c.String("format") + "\n") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, build := range builds { | ||
tmpl.Execute(os.Stdout, build) | ||
} | ||
return nil | ||
} | ||
|
||
var tmplStage = "\x1b[33mitem #{{ .ID }} \x1b[0m" + ` | ||
Status: {{ .Status }} | ||
Machine: {{ .Machine }} | ||
OS: {{ .OS }} | ||
Arch: {{ .Arch }} | ||
Variant: {{ .Variant }} | ||
Version: {{ .Kernel }} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package queue | ||
|
||
import ( | ||
"github.com/drone/drone-cli/drone/internal" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var queuePauseCmd = cli.Command{ | ||
Name: "pause", | ||
Usage: "pause queue operations", | ||
Action: queuePause, | ||
} | ||
|
||
func queuePause(c *cli.Context) (err error) { | ||
client, err := internal.NewClient(c) | ||
if err != nil { | ||
return err | ||
} | ||
return client.QueuePause() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package queue | ||
|
||
import ( | ||
"github.com/drone/drone-cli/drone/internal" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var queueResumeCmd = cli.Command{ | ||
Name: "resume", | ||
Usage: "resume queue operations", | ||
Action: queueResume, | ||
} | ||
|
||
func queueResume(c *cli.Context) (err error) { | ||
client, err := internal.NewClient(c) | ||
if err != nil { | ||
return err | ||
} | ||
return client.QueueResume() | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.