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) }
func Configure(ctx *cli.Context) { slug := ctx.Args().First() project, err := models.GetProject(slug) utils.ExitIfErr(err) err = confFunc(project) utils.ExitIfErr(err) }
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) }
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) }
// auth.Logout wrapper with a cli.Content func Logout(ctx *cli.Context) { err := logout() utils.ExitIfErr(err) }
func DependencyAlertsList(ctx *cli.Context) { project, err := models.GetProject(ctx.Args().First()) utils.ExitIfErr(err) err = models.ListDependencyAlerts(project) utils.ExitIfErr(err) }
func DependencyFilesList(ctx *cli.Context) { project, err := models.GetProject() utils.ExitIfErr(err) err = models.ListDependencyFiles(project) utils.ExitIfErr(err) }
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) }
func ProjectsSync(ctx *cli.Context) { project, err := models.GetProject(ctx.Args().First()) utils.ExitIfErr(err) err = project.Sync() utils.ExitIfErr(err) }
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) }
func ProjectsList(ctx *cli.Context) { err := models.ListProjects(ctx.Bool("private")) utils.ExitIfErr(err) }
func main() { app, err := commands.App() utils.ExitIfErr(err) app.Run(os.Args) }