Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Delete = app.Register(&app.Command[app.Empty, app.Empty]{ Use: "workflow {name}", Desc: "Delete a workflow", Action: "Delete", PrepareNoFlag: func(cmd *cobra.Command) { cmd.Args = cobra.ExactArgs(1) cmd.ValidArgsFunction = app.Comp(app.CompWorkflow) }, Run: func(ctx *app.Context[app.Empty, app.Empty]) error { name := ctx.Arg(0) path := config.GetDir("workflows", name+".yaml") return app.Delete(ctx.Arg(0), path) }, })
View Source
var Edit = app.Register(&app.Command[app.Empty, app.Empty]{ Use: "workflow {workflow}", Desc: "Edit workflow file", Action: "Edit", PrepareNoFlag: func(cmd *cobra.Command) { cmd.Args = cobra.ExactArgs(1) cmd.ValidArgsFunction = app.Comp(app.CompWorkflow) }, Run: func(ctx *app.Context[app.Empty, app.Empty]) error { name := fmt.Sprintf("%s.yaml", ctx.Arg(0)) path := config.GetDir("workflows", name) return app.Edit(path, config.DefaultWorkflow, name, func(s string) error { data := []byte(s) var wf core.Workflow err := yaml.Unmarshal(data, &wf) if err != nil { return errors.Trace(err, "parse yaml") } return validate.Do(&wf) }) }, })
View Source
var Workflow = app.Register(&app.Command[WorkflowFlags, app.Empty]{ Use: "run [-y] [-c] {workflow}", Desc: "Run workflow", Prepare: func(cmd *cobra.Command, flags *WorkflowFlags) { cmd.Flags().BoolVarP(&flags.Current, "current", "c", false, "run workflow on current repo") cmd.Flags().BoolVarP(&flags.Edit, "edit", "e", false, "edit repo to run") cmd.Flags().StringVarP(&flags.LogPath, "log-path", "", "", "log file path") cmd.Args = cobra.ExactArgs(1) cmd.ValidArgsFunction = app.Comp(app.CompWorkflow) }, Run: func(ctx *app.Context[WorkflowFlags, app.Empty]) error { wf, err := core.GetWorkflow(ctx.Arg(0)) if err != nil { return err } store, err := core.NewRepositoryStorage() if err != nil { return err } store.ReadOnly() if ctx.Flags.Current { return workflowRunCurrent(store, wf) } if wf.Select == nil { term.Println("nothing to do") return nil } items, err := wf.Select.Match(store) if err != nil { return err } if len(items) == 0 { term.Println("no repo selected") return nil } if ctx.Flags.Edit { items, err = term.EditItems(config.Get().Editor, items, func(item *core.WorkflowMatchItem) string { return item.Path }) if err != nil { return err } } repoWord := english.Plural(len(items), "repo", "repos") term.ConfirmExit("Do you want to run workflow %s for %s", ctx.Arg(0), repoWord) return workflowRun(ctx, wf.Jobs, items) }, })
Functions ¶
This section is empty.
Types ¶
type WorkflowFlags ¶
Click to show internal directories.
Click to hide internal directories.