cli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess   = 0 // Successful execution
	ExitUserError = 1 // User/input error (invalid args, missing required values)
	ExitAPIError  = 2 // API error (4xx/5xx responses, except auth)
	ExitNetError  = 3 // Network/connection error
	ExitAuthError = 4 // Authentication error (401, 403)
	ExitPartial   = 5 // Partial failure in batch operations
)

Exit codes for the CLI.

Variables

View Source
var (
	// Version is set at build time via -ldflags.
	Version = "dev"
)

Functions

func Board

func Board() string

Board returns the current board ID.

func DryRun

func DryRun() bool

DryRun returns true if dry-run mode is enabled.

func Execute

func Execute() error

func ExitCodeFromError

func ExitCodeFromError(err error) int

ExitCodeFromError determines the appropriate exit code for an error. Returns ExitSuccess (0) if err is nil.

func FormatFileSize

func FormatFileSize(bytes int64) string

FormatFileSize formats a file size in bytes to a human-readable string. Uses 1024-based units with SI prefixes (KB, MB, GB).

func IssueURL

func IssueURL(baseURL, key string) string

IssueURL returns the browse URL for an issue key.

func JSONOutput

func JSONOutput() bool

JSONOutput returns true if JSON output is requested.

func NoColor

func NoColor() bool

NoColor returns true if colour output is disabled.

func PrintBatchResults

func PrintBatchResults(results []BatchResult) error

PrintBatchResults prints batch operation results. Returns an ExitError with ExitPartial if there were any failures.

func PrintDryRun

func PrintDryRun(action string)

PrintDryRun prints what would happen for a single operation.

func PrintDryRunBatch

func PrintDryRunBatch(keys []string, action string)

PrintDryRunBatch prints what would happen for a batch operation.

func PrintSuccess

func PrintSuccess(message string)

PrintSuccess prints a success message unless quiet mode is enabled.

func PrintSuccessJSON

func PrintSuccessJSON(v any)

PrintSuccessJSON prints JSON output unless quiet mode is enabled.

func Project

func Project() string

Project returns the current project key.

func ProjectURL

func ProjectURL(baseURL, projectKey string) string

ProjectURL returns the browse URL for a project key.

func Quiet

func Quiet() bool

Quiet returns true if quiet mode is enabled.

func ReadKeysFromStdin

func ReadKeysFromStdin() ([]string, error)

ReadKeysFromStdin reads issue keys from stdin (one per line).

func RenderMarkdown

func RenderMarkdown(markdown string) string

RenderMarkdown renders markdown with terminal styling. Falls back to plain text if rendering fails, output is not a TTY, or --no-color is set.

func Verbose

func Verbose() bool

Verbose returns true if verbose mode is enabled.

Types

type AttachmentAddResult

type AttachmentAddResult struct {
	IssueKey    string           `json:"issueKey"`
	Attachments []AttachmentInfo `json:"attachments"`
}

AttachmentAddResult represents the result of adding attachments.

type AttachmentDownloadResult

type AttachmentDownloadResult struct {
	ID       string `json:"id"`
	Filename string `json:"filename"`
	Size     int64  `json:"size"`
	Output   string `json:"output"`
}

AttachmentDownloadResult represents the result of downloading an attachment.

type AttachmentInfo

type AttachmentInfo struct {
	ID       string `json:"id"`
	Filename string `json:"filename"`
	Size     int64  `json:"size"`
	MimeType string `json:"mimeType"`
	Author   string `json:"author"`
	Created  string `json:"created"`
	Content  string `json:"content,omitempty"`
}

AttachmentInfo represents an attachment for display.

type AttachmentRemoveResult

type AttachmentRemoveResult struct {
	IssueKey string   `json:"issueKey"`
	Removed  []string `json:"removed"`
	Count    int      `json:"count"`
}

AttachmentRemoveResult represents the result of removing attachments.

type BatchResult

type BatchResult struct {
	Key     string `json:"key"`
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty"`
}

BatchResult represents the outcome of a single batch operation.

type BatchSummary

type BatchSummary struct {
	Results   []BatchResult `json:"results"`
	Total     int           `json:"total"`
	Succeeded int           `json:"succeeded"`
	Failed    int           `json:"failed"`
}

BatchSummary represents the overall batch operation outcome.

type BoardInfo

type BoardInfo struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	Project string `json:"project,omitempty"`
}

BoardInfo represents a Jira board for output.

type CloneResult

type CloneResult struct {
	OriginalKey string `json:"originalKey"`
	ClonedKey   string `json:"clonedKey"`
	ClonedID    string `json:"clonedId"`
	Linked      bool   `json:"linked"`
	LinkType    string `json:"linkType,omitempty"`
}

CloneResult represents the result of cloning an issue.

type CommentInfo

type CommentInfo struct {
	ID      string `json:"id"`
	Author  string `json:"author"`
	Created string `json:"created"`
	Body    string `json:"body"`
}

CommentInfo represents a comment on an issue.

type CommentResult

type CommentResult struct {
	ID      string `json:"id"`
	Self    string `json:"self"`
	Created string `json:"created"`
}

CommentResult represents the result of adding a comment.

type CreateResult

type CreateResult struct {
	Key  string `json:"key"`
	ID   string `json:"id"`
	Self string `json:"self"`
}

CreateResult represents the result of creating an issue.

type ExitError

type ExitError struct {
	Code int
	Err  error
}

ExitError wraps an error with an exit code.

func NewExitError

func NewExitError(code int, err error) *ExitError

NewExitError creates a new ExitError with the given code and error.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type FieldInfo

type FieldInfo struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Custom bool   `json:"custom"`
	Type   string `json:"type,omitempty"`
}

FieldInfo represents a Jira field.

type IssueDetail

type IssueDetail struct {
	Key           string           `json:"key"`
	Summary       string           `json:"summary"`
	Status        string           `json:"status"`
	Type          string           `json:"type"`
	Priority      string           `json:"priority"`
	Assignee      string           `json:"assignee"`
	Reporter      string           `json:"reporter"`
	Created       string           `json:"created"`
	Updated       string           `json:"updated"`
	Description   string           `json:"description"`
	Labels        []string         `json:"labels"`
	Project       string           `json:"project"`
	Links         []LinkInfo       `json:"links,omitempty"`
	Attachments   []AttachmentInfo `json:"attachments,omitempty"`
	Comments      []CommentInfo    `json:"comments,omitempty"`
	TotalComments int              `json:"total_comments,omitempty"`
}

IssueDetail represents a full Jira issue for output.

type IssueInfo

type IssueInfo struct {
	Key            string `json:"key"`
	Summary        string `json:"summary"`
	Status         string `json:"status"`
	StatusCategory string `json:"statusCategory"`
	Type           string `json:"type"`
	Priority       string `json:"priority"`
	Assignee       string `json:"assignee"`
}

IssueInfo represents a Jira issue for output.

type LinkInfo

type LinkInfo struct {
	Direction string `json:"direction"`
	Key       string `json:"key"`
	Status    string `json:"status"`
	Summary   string `json:"summary"`
}

LinkInfo represents a linked issue for display.

type LinkResult

type LinkResult struct {
	OutwardIssue string `json:"outwardIssue"`
	InwardIssue  string `json:"inwardIssue"`
	Type         string `json:"type"`
}

LinkResult represents the result of creating a link.

type ProjectInfo

type ProjectInfo struct {
	ID    string `json:"id"`
	Key   string `json:"key"`
	Name  string `json:"name"`
	Lead  string `json:"lead"`
	Style string `json:"style"`
}

ProjectInfo represents a Jira project.

type ReleaseInfo

type ReleaseInfo struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Released    bool   `json:"released"`
	Archived    bool   `json:"archived"`
	ReleaseDate string `json:"releaseDate,omitempty"`
	StartDate   string `json:"startDate,omitempty"`
}

ReleaseInfo represents a project version/release.

type RemoteLinkResult

type RemoteLinkResult struct {
	ID    int    `json:"id"`
	Self  string `json:"self"`
	Issue string `json:"issue"`
	URL   string `json:"url"`
	Title string `json:"title"`
}

RemoteLinkResult represents the result of adding a remote link.

type RemoveResult

type RemoveResult struct {
	Issue1       string `json:"issue1"`
	Issue2       string `json:"issue2"`
	LinksRemoved int    `json:"linksRemoved"`
}

RemoveResult represents the result of removing links.

type SprintInfo

type SprintInfo struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	State     string `json:"state"`
	StartDate string `json:"startDate,omitempty"`
	EndDate   string `json:"endDate,omitempty"`
	Goal      string `json:"goal,omitempty"`
}

SprintInfo represents a Jira sprint for output.

type User

type User struct {
	AccountID    string `json:"accountId"`
	DisplayName  string `json:"displayName"`
	EmailAddress string `json:"emailAddress"`
	TimeZone     string `json:"timeZone"`
	Active       bool   `json:"active"`
}

User represents the current user from /myself endpoint.

type UserInfo

type UserInfo struct {
	AccountID    string `json:"accountId"`
	DisplayName  string `json:"displayName"`
	EmailAddress string `json:"emailAddress,omitempty"`
	Active       bool   `json:"active"`
}

UserInfo represents a Jira user.

Jump to

Keyboard shortcuts

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