jql

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jql builds and composes Jira Query Language strings from structured inputs. It is pure string logic — no cobra, config, or I/O — so the jql/search/issue command layers and shell completion can all share one query builder without import cycles.

It is the single composition path: every command builds its query through Build (filters → ORDER BY) or IssueList (raw JQL + filters + ORDER BY); every value is quoted through the one quoter, Value (safe identifier bare, otherwise double-quoted with embedded quotes escaped); and top-level ORDER BY / OR detection goes through the one quote-aware tokenizer (topLevelWordTokens, SplitTopLevelOrderBy). Board scoping composes on top via CombineClauses / ParenthesizeIfTopLevelOR rather than re-implementing any of it. Keep new JQL construction here — command layers must not hand-build clause strings, so the quoting and precedence rules cannot drift per command.

Index

Constants

View Source
const DefaultIssueListJQL = "updated >= -365d ORDER BY updated DESC"

DefaultIssueListJQL is the bounded default query used when an issue list is requested with no filters and no explicit sort. It is owned here, in the query domain, and consumed by the Jira issue service as its List default.

View Source
const EpicListJQL = "issuetype = Epic"

EpicListJQL selects epics. It is owned here so the epic service (which runs it) and the epic command layer (which echoes it) share one literal and can't drift in spelling or spacing.

Variables

This section is empty.

Functions

func CombineClauses

func CombineClauses(lhs, rhs string) string

CombineClauses AND-joins two JQL fragments, dropping either side when blank.

func CompactStrings

func CompactStrings(values []string) []string

CompactStrings returns values with empty/whitespace-only entries dropped and the rest trimmed.

func IssueList

func IssueList(raw string, builder BuildOptions) (string, error)

IssueList combines a raw JQL string with the builder's structured filters. A non-empty raw query is parenthesized and AND-ed beneath the filters. The raw query's own top-level ORDER BY always wins; when it has none, the builder's --order-by is applied (an empty or "none" order-by adds nothing). An empty raw query falls back to Build.

func ParenthesizeIfTopLevelOR

func ParenthesizeIfTopLevelOR(query string) string

ParenthesizeIfTopLevelOR wraps query in parentheses only when it contains a top-level OR, so AND-composition with another clause keeps the original precedence.

func SplitTopLevelOrderBy

func SplitTopLevelOrderBy(query string) (string, string)

SplitTopLevelOrderBy splits query into the filter portion and a leading-space " ORDER BY ..." suffix (empty when there is no top-level ORDER BY).

func Value added in v0.3.3

func Value(value string) string

Value renders a string as a JQL value: a safe identifier (letters, digits, _ - .) is returned bare; anything else is double-quoted with embedded quotes escaped. It is the one quoter every clause goes through — exported so the few service-layer clauses that can't use the full builder (e.g. a bare "parent = KEY") still quote identically rather than rolling their own.

Types

type BuildOptions

type BuildOptions struct {
	Projects   []string
	Keys       []string
	Epics      []string
	Assignee   string
	Reporter   string
	Statuses   []string
	Priorities []string
	Labels     []string
	IssueTypes []string
	Updated    string
	Created    string
	Resolved   string
	OrderBy    string
	Descending bool
}

BuildOptions captures the structured filters that compose into a JQL query.

func (BuildOptions) Build

func (o BuildOptions) Build() (string, error)

Build renders the options into a complete JQL query (with ORDER BY). With no filters and no explicit sort it returns the default bounded issue list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL