Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Create = app.Register(&app.Command[CreateFlags, app.Empty]{ Use: "play [-b builder] {play}", Desc: "Create a playground", Action: "Create", Prepare: func(cmd *cobra.Command, flags *CreateFlags) { cmd.Flags().StringVarP(&flags.Builder, "builder", "b", "", "builder name") cmd.RegisterFlagCompletionFunc("builder", app.Comp(app.CompBuilder)) cmd.Flags().StringSliceVarP(&flags.Template, "template", "t", nil, "template to use") cmd.RegisterFlagCompletionFunc("template", app.Comp(app.CompTemplate)) cmd.Args = cobra.ExactArgs(1) cmd.ValidArgsFunction = app.Comp(compGroup) }, Run: func(ctx *app.Context[CreateFlags, app.Empty]) error { var err error builder := core.DefaultBuilder if ctx.Flags.Builder != "" { builder, err = core.GetBuilder(ctx.Flags.Builder) if err != nil { return err } } if len(ctx.Flags.Template) > 0 { builder.Templates = append(builder.Templates, ctx.Flags.Template...) } rootDir := config.Get().Playground repo, err := core.NewLocalRepository(rootDir, ctx.Arg(0)) if err != nil { return err } err = builder.Prepare(nil, repo) if err != nil { return err } err = builder.Execute() if err != nil { return err } fmt.Println(repo.Path) return nil }, })
View Source
var Delete = app.Register(&app.Command[app.Empty, app.Empty]{ Use: "play {name}", Desc: "Delete a playground", Action: "Delete", PrepareNoFlag: func(cmd *cobra.Command) { cmd.Args = cobra.MaximumNArgs(1) cmd.ValidArgsFunction = app.Comp(compRepo) }, Run: func(ctx *app.Context[app.Empty, app.Empty]) error { rootDir := config.Get().Playground repo, err := core.SelectLocalRepository(rootDir, ctx.Arg(0)) if err != nil { return err } term.ConfirmExit("Do you want to remove %s", repo.Path) return os.RemoveAll(repo.Path) }, })
View Source
var Home = app.Register(&app.Command[app.Empty, app.Empty]{ Use: "play [name]", Desc: "Enter a playground", PrepareNoFlag: func(cmd *cobra.Command) { cmd.Args = cobra.MaximumNArgs(1) cmd.ValidArgsFunction = app.Comp(compRepo) }, Run: func(ctx *app.Context[app.Empty, app.Empty]) error { rootDir := config.Get().Playground repo, err := core.SelectLocalRepository(rootDir, ctx.Arg(0)) if err != nil { return err } fmt.Println(repo.Path) return nil }, })
Functions ¶
This section is empty.
Types ¶
type CreateFlags ¶
Click to show internal directories.
Click to hide internal directories.