Example #1
0
func AutoUpdateApply(ctx *cli.Context) {
	auth.AttemptLogin(ctx)
	project, err := models.GetProject(ctx.String("project"))
	utils.ExitIfErr(err)
	err = auApplyFunc(project.Slug, ctx.Args())
	utils.ExitIfErr(err)
}
Example #2
0
func Configure(ctx *cli.Context) {
	slug := ctx.Args().First()
	project, err := models.GetProject(slug)
	utils.ExitIfErr(err)

	err = confFunc(project)
	utils.ExitIfErr(err)
}
Example #3
0
func DependenciesPush(ctx *cli.Context) {
	project, err := models.GetProject()
	utils.ExitIfErr(err)
	var files []string
	if ctx.IsSet("files") {
		// Only call strings.Split on non-empty strings, otherwise len(strings) will be 1 instead of 0.
		files = strings.Split(ctx.String("files"), ",")
	}
	err = models.PushDependencyFiles(project.Slug, files)
	utils.ExitIfErr(err)
}
Example #4
0
func ProjectsUpdate(ctx *cli.Context) {
	project, err := models.GetProject(ctx.Args().First())
	utils.ExitIfErr(err)
	var name, desc *string
	var monitored *bool
	if ctx.IsSet("name") {
		nameString := ctx.String("name")
		name = &nameString
	}
	if ctx.IsSet("desc") {
		descString := ctx.String("desc")
		desc = &descString
	}
	if ctx.IsSet("monitored") {
		mon := ctx.Bool("monitored")
		monitored = &mon
	}
	err = project.Update(name, desc, monitored)
	utils.ExitIfErr(err)
}
Example #5
0
// auth.Logout wrapper with a cli.Content
func Logout(ctx *cli.Context) {
	err := logout()
	utils.ExitIfErr(err)
}
Example #6
0
func DependencyAlertsList(ctx *cli.Context) {
	project, err := models.GetProject(ctx.Args().First())
	utils.ExitIfErr(err)
	err = models.ListDependencyAlerts(project)
	utils.ExitIfErr(err)
}
Example #7
0
func DependencyFilesList(ctx *cli.Context) {
	project, err := models.GetProject()
	utils.ExitIfErr(err)
	err = models.ListDependencyFiles(project)
	utils.ExitIfErr(err)
}
Example #8
0
package commands

import (
	"os"

	"github.com/codegangsta/cli"
	"github.com/gemnasium/toolbelt/models"
	"github.com/gemnasium/toolbelt/utils"
)

var confFunc = func(project *models.Project) error {
	f, err := os.Create(".gemnasium.yml")
	utils.ExitIfErr(err)
	defer f.Close()
	return project.Configure(project.Slug, os.Stdin, f)
}

func Configure(ctx *cli.Context) {
	slug := ctx.Args().First()
	project, err := models.GetProject(slug)
	utils.ExitIfErr(err)

	err = confFunc(project)
	utils.ExitIfErr(err)
}
Example #9
0
func ProjectsSync(ctx *cli.Context) {
	project, err := models.GetProject(ctx.Args().First())
	utils.ExitIfErr(err)
	err = project.Sync()
	utils.ExitIfErr(err)
}
Example #10
0
func ProjectsCreate(ctx *cli.Context) {
	projectName := ctx.Args().First()
	// will scan from os.Stding if projectName is empty
	err := models.CreateProject(projectName, os.Stdin)
	utils.ExitIfErr(err)
}
Example #11
0
func ProjectsList(ctx *cli.Context) {
	err := models.ListProjects(ctx.Bool("private"))
	utils.ExitIfErr(err)
}
Example #12
0
func main() {
	app, err := commands.App()
	utils.ExitIfErr(err)
	app.Run(os.Args)
}