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

Code before:
			if opts.ProblemStatement == "" {
				return cmdutil.FlagErrorf("a task description is required")
			}
			// Support -R/--repo override
			if f != nil {
				opts.BaseRepo = f.BaseRepo
			}
			if runF != nil {
				return runF(opts)
			}
			return createRun(opts)
		},
		Example: heredoc.Doc(`
			# Create a task from an inline description
			$ gh agent-task create "build me a new app"

			# Create a task from a file
			$ gh agent-task create -F task-desc.md
		`),
	}
	if f != nil {
		cmdutil.EnableRepoOverride(cmd, f)
	}

	cmd.Flags().StringVarP(&fromFileName, "from-file", "F", "", "Read task description from file")

	opts.CapiClient = func() (capi.CapiClient, error) {
		cfg, err := f.Config()
		if err != nil {
			return nil, err
		}
		httpClient, err := f.HttpClient()
		if err != nil {
			return nil, err
		}
		authCfg := cfg.Authentication()
		return capi.NewCAPIClient(httpClient, authCfg), nil
	}

	return cmd
}

func createRun(opts *CreateOptions) error {
	if opts.ProblemStatement == "" {
		return cmdutil.FlagErrorf("a task description is required")
	}
	if opts.BaseRepo == nil {
		return errors.New("failed to resolve repository")
	}
	repo, err := opts.BaseRepo()
	if err != nil || repo == nil {

Review comment (suggestion):
As I'm taking `pr create` as a reference command that supports reading from a file:
- We should mention the use of `-` to read from stdin
- We should enclose "file" in the usage string in backticks to make it render as the arg name in the `--help` output. I mean like this in `pr create` docs (note the "file" next to "--body-file"):
  ```
  -F, --body-file file       Read body text from file (use "-" to read from standard input)
  ```

If you're up for the changes, here's the change:

```suggestion
	cmd.Flags().StringVarP(&fromFileName, "from-file", "F", "", "Read task description from `file` (use \"-\" to read from standard input)"
```

Code after:
			}
			if opts.ProblemStatement == "" {
				return cmdutil.FlagErrorf("a task description is required")
			}
			// Support -R/--repo override
			if f != nil {
				opts.BaseRepo = f.BaseRepo
			}
			if runF != nil {
				return runF(opts)
			}
			return createRun(opts)
		},
		Example: heredoc.Doc(`
			# Create a task from an inline description
			$ gh agent-task create "build me a new app"

			# Create a task from a file
			$ gh agent-task create -F task-desc.md
		`),
	}
	if f != nil {
		cmdutil.EnableRepoOverride(cmd, f)
	}

	cmd.Flags().StringVarP(&fromFileName, "from-file", "F", "", "Read task description from file")
	cmd.Flags().StringVarP(&opts.BaseBranch, "base", "b", "", "Base branch for the task")

	opts.CapiClient = func() (capi.CapiClient, error) {
		cfg, err := f.Config()
		if err != nil {
			return nil, err
		}
		httpClient, err := f.HttpClient()
		if err != nil {
			return nil, err
		}
		authCfg := cfg.Authentication()
		return capi.NewCAPIClient(httpClient, authCfg), nil
	}

	return cmd
}

func createRun(opts *CreateOptions) error {
	if opts.ProblemStatement == "" {
		return cmdutil.FlagErrorf("a task description is required")
	}
	if opts.BaseRepo == nil {
		return errors.New("failed to resolve repository")
	}