From f53f8a841f19ec1d35115fc804f31c8bace6fe84 Mon Sep 17 00:00:00 2001 From: Craig Miskell Date: Wed, 10 Dec 2025 14:36:41 +1300 Subject: [PATCH 1/3] feat: Add --template argument for issue create The interactive command allows selecting a template, but fully automated operation does not. This adds a `--template` arg that can be used in either interactive or non-interactive mode to select and use the given template. --- internal/commands/issue/create/issue_create.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/commands/issue/create/issue_create.go b/internal/commands/issue/create/issue_create.go index 38f0bebff..297b0d0b9 100644 --- a/internal/commands/issue/create/issue_create.go +++ b/internal/commands/issue/create/issue_create.go @@ -52,6 +52,7 @@ type options struct { DueDate string `json:"due_date,omitempty"` MilestoneFlag string `json:"milestone_flag"` + Template string `json:"template,omitempty"` IsConfidential bool `json:"is_confidential,omitempty"` @@ -163,6 +164,7 @@ func NewCmdCreate(f cmdutils.Factory) *cobra.Command { issueCreateCmd.Flags().BoolVar(&opts.recover, "recover", false, "Save the options to a file if the issue fails to be created. If the file exists, the options will be loaded from the recovery file. (EXPERIMENTAL)") issueCreateCmd.Flags().Int64VarP(&opts.EpicID, "epic", "", 0, "ID of the epic to add the issue to.") issueCreateCmd.Flags().StringVarP(&opts.DueDate, "due-date", "", "", "A date in 'YYYY-MM-DD' format.") + issueCreateCmd.Flags().StringVarP(&opts.Template, "template", "", "", "Use a specific issue template by name.") return issueCreateCmd } @@ -201,9 +203,21 @@ var createRun = func(opts *options) error { } } + if opts.Template != "" { + templateContents, err = cmdutils.LoadGitLabTemplate(cmdutils.IssueTemplate, opts.Template) + if err != nil { + return fmt.Errorf("failed to load template %q: %w", opts.Template, err) + } + templateName = opts.Template + // If description is empty, use template contents + if opts.Description == "" { + opts.Description = templateContents + } + } + if opts.isInteractive { // Step 1: Template selection (if not using --no-editor and description is empty) - if opts.Description == "" && !opts.noEditor { + if opts.Description == "" && !opts.noEditor && opts.Template == "" { templateNames, err := cmdutils.ListGitLabTemplates(cmdutils.IssueTemplate) if err != nil { return fmt.Errorf("error getting templates: %w", err) -- GitLab From 3f6475b5ff8f8b33a87477e6ce194dd22521a9e5 Mon Sep 17 00:00:00 2001 From: Craig Miskell Date: Wed, 10 Dec 2025 14:51:26 +1300 Subject: [PATCH 2/3] Generate docs --- docs/source/issue/create.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/issue/create.md b/docs/source/issue/create.md index 429300702..d91f6cf5b 100644 --- a/docs/source/issue/create.md +++ b/docs/source/issue/create.md @@ -48,6 +48,7 @@ $ glab issue create -m release-1.0.1 -t "security fix" --label security --web -- -m, --milestone string The global ID or title of a milestone to assign. --no-editor Don't open editor to enter a description. If set to true, uses prompt. (default false) --recover Save the options to a file if the issue fails to be created. If the file exists, the options will be loaded from the recovery file. (EXPERIMENTAL) + --template string Use a specific issue template by name. -e, --time-estimate string Set time estimate for the issue. -s, --time-spent string Set time spent for the issue. -t, --title string Issue title. -- GitLab From 3f33a56c4b22e74bb7f094e9cc146ba55bf6a012 Mon Sep 17 00:00:00 2001 From: Craig Miskell Date: Wed, 10 Dec 2025 15:08:29 +1300 Subject: [PATCH 3/3] oh how embarrassing --- internal/commands/issue/create/issue_create.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/commands/issue/create/issue_create.go b/internal/commands/issue/create/issue_create.go index 297b0d0b9..f025a29a0 100644 --- a/internal/commands/issue/create/issue_create.go +++ b/internal/commands/issue/create/issue_create.go @@ -208,7 +208,6 @@ var createRun = func(opts *options) error { if err != nil { return fmt.Errorf("failed to load template %q: %w", opts.Template, err) } - templateName = opts.Template // If description is empty, use template contents if opts.Description == "" { opts.Description = templateContents -- GitLab