Repository: cli/cli
File: pkg/cmd/agent-task/create/create.go (Go)

Code before:
	"github.com/cli/cli/v2/internal/prompter"
	"github.com/cli/cli/v2/pkg/cmd/agent-task/capi"
	"github.com/cli/cli/v2/pkg/cmd/agent-task/shared"
	"github.com/cli/cli/v2/pkg/cmdutil"
	"github.com/cli/cli/v2/pkg/iostreams"
	"github.com/spf13/cobra"
)

// CreateOptions holds options for create command
type CreateOptions struct {
	IO               *iostreams.IOStreams
	BaseRepo         func() (ghrepo.Interface, error)
	CapiClient       func() (capi.CapiClient, error)
	Config           func() (gh.Config, error)
	ProblemStatement string
	BackOff          backoff.BackOff
	BaseBranch       string
	Prompter         prompter.Prompter
}

func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Command {
	opts := &CreateOptions{
		IO:         f.IOStreams,
		CapiClient: shared.CapiClientFunc(f),
		Prompter:   f.Prompter,
	}

	var fromFileName string

	cmd := &cobra.Command{
		Use:   "create [<task description>] [flags]",
		Short: "Create an agent task (preview)",
		Args:  cobra.MaximumNArgs(1),
		RunE: func(cmd *cobra.Command, args []string) error {
			// Support -R/--repo override
			opts.BaseRepo = f.BaseRepo

			if err := cmdutil.MutuallyExclusive("only one of -F or arg can be provided", len(args) > 0, fromFileName != ""); err != nil {
				return err
			}

			// Gather arg inputs for ProblemStatement
			if len(args) > 0 {
				opts.ProblemStatement = args[0]
			} else if fromFileName != "" {
				fileContent, err := cmdutil.ReadFile(fromFileName, opts.IO.In)
				if err != nil {
					return cmdutil.FlagErrorf("could not read task description file: %v", err)
				}
				trimmed := strings.TrimSpace(string(fileContent))
				if trimmed == "" {

Review comment (suggestion):
We can also add assign `Config` here:


```suggestion
		Prompter:   f.Prompter,
        Config:     f.Config,
```

Code after:
	"github.com/cli/cli/v2/internal/prompter"
	"github.com/cli/cli/v2/pkg/cmd/agent-task/capi"
	"github.com/cli/cli/v2/pkg/cmd/agent-task/shared"
	"github.com/cli/cli/v2/pkg/cmdutil"
	"github.com/cli/cli/v2/pkg/iostreams"
	"github.com/spf13/cobra"
)

// CreateOptions holds options for create command
type CreateOptions struct {
	IO               *iostreams.IOStreams
	BaseRepo         func() (ghrepo.Interface, error)
	CapiClient       func() (capi.CapiClient, error)
	Config           func() (gh.Config, error)
	ProblemStatement string
	BackOff          backoff.BackOff
	BaseBranch       string
	Prompter         prompter.Prompter
}

func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Command {
	opts := &CreateOptions{
		IO:         f.IOStreams,
		CapiClient: shared.CapiClientFunc(f),
		Config:     f.Config,
		Prompter:   f.Prompter,
	}

	var fromFileName string

	cmd := &cobra.Command{
		Use:   "create [<task description>] [flags]",
		Short: "Create an agent task (preview)",
		Args:  cobra.MaximumNArgs(1),
		RunE: func(cmd *cobra.Command, args []string) error {
			// Support -R/--repo override
			opts.BaseRepo = f.BaseRepo

			if err := cmdutil.MutuallyExclusive("only one of -F or arg can be provided", len(args) > 0, fromFileName != ""); err != nil {
				return err
			}

			// Gather arg inputs for ProblemStatement
			if len(args) > 0 {
				opts.ProblemStatement = args[0]
			} else if fromFileName != "" {
				fileContent, err := cmdutil.ReadFile(fromFileName, opts.IO.In)
				if err != nil {
					return cmdutil.FlagErrorf("could not read task description file: %v", err)
				}
				trimmed := strings.TrimSpace(string(fileContent))