shared

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shared holds what the issue commands have in common: issue arguments, the --json field contract and issue URLs.

Index

Constants

View Source
const FieldsFlagHelp = `--field "Name=Value" sets a custom field and can be repeated. The value is
checked against the project's field definitions: enum, state, version,
build, owned and group fields take an element name (case is ignored), user
fields a login or "me", date fields YYYY-MM-DD, date-time fields
2026-10-07T14:30 (local time) or RFC 3339, number fields a number, and text
and string fields any text. Multi-value fields take a comma-separated list,
which replaces their values; to add or remove one value, use
` + "`ytrack issue command <id> 'add <Field> <value>'` or `'remove <Field> <value>'`" + `.
"Name=" clears a field unless the project requires a value. Period fields such as
Estimation take a duration like "1w 2d 4h" and are set with a YouTrack
command, so the instance's work schedule applies; everything else is
written through the REST API. For anything else, use ` + "`ytrack issue command`."

FieldsFlagHelp documents --field for command help.

View Source
const IssueFieldsHelp = `` /* 824-byte string literal not displayed */

IssueFieldsHelp documents IssueFields for command help.

Variables

View Source
var IssueFields = []string{
	"id", "idReadable", "summary", "description", "project", "state", "priority",
	"assignee", "reporter", "created", "updated", "resolved", "tags", "url", "customFields",
}

IssueFields are the --json fields of an issue.

Functions

func Attrs

func Attrs(jsonFields []string, extra ...string) []string

Attrs returns the adapter attributes needed for the requested --json fields plus extra.

func CommentURL

func CommentURL(host hosts.Host, issueID, commentID string) string

CommentURL is the web URL of a comment.

func CompleteIssues added in v0.2.0

func CompleteIssues(f *cmdutil.Factory, maxArgs int) cobra.CompletionFunc

CompleteIssues completes issue IDs for the first maxArgs positional arguments (every argument when maxArgs < 0) with the 50 most recently updated unresolved issues, narrowed to a project once the word has one ("APP-"). Each suggestion carries the issue summary. Errors, such as no login, complete nothing and print nothing.

func CompleteProjects added in v0.2.0

func CompleteProjects(f *cmdutil.Factory) cobra.CompletionFunc

CompleteProjects completes a --project flag with the short names of projects that are not archived.

func FindProject

func FindProject(ctx context.Context, c *transport.Client, key string) (adapter.ProjectInfo, error)

FindProject finds a project that is not archived by key: an exact short name first, then a short name ignoring case, then a name ignoring case, which must match one project only.

func IssueURL

func IssueURL(host hosts.Host, id string) string

IssueURL is the web URL of an issue.

func NotFound

func NotFound(err error, id string, host hosts.Host) error

NotFound turns a 404 for issue id into a clear message.

func ParsedCommands

func ParsedCommands(cs []adapter.ParsedCommand) []map[string]any

ParsedCommands exports YouTrack's parse of a command for --json.

func ResolveTags

func ResolveTags(ctx context.Context, c *transport.Client, names []string) ([]adapter.Tag, error)

ResolveTags finds the tags called names, exactly or else ignoring case.

func UseRefHost

func UseRefHost(f *cmdutil.Factory, ref Ref, sendsToken bool) error

UseRefHost points f at the host of an issue URL. A --host or $YTRACK_HOST naming a different host is a usage error. When sendsToken is set and $YTRACK_TOKEN is in use, the URL's host must be a logged-in host in hosts.yml or be named by --host or $YTRACK_HOST: a pasted link must not pick where the token goes.

func UseRefHostForWrite

func UseRefHostForWrite(f *cmdutil.Factory, ref Ref) error

UseRefHostForWrite is UseRefHost for commands that change data: an issue URL must be on a logged-in host (one in hosts.yml) unless --host or $YTRACK_HOST names it, whatever the token source. A pasted link never picks where a write goes.

func Zone

func Zone(f *cmdutil.Factory) (*time.Location, error)

Zone is the configured timezone (config.yml "timezone"), else the clock's.

Types

type DescriptionFlags

type DescriptionFlags struct {
	Text   string
	File   string
	Editor bool
	// contains filtered or unexported fields
}

DescriptionFlags are --description, --description-file and --editor.

func (*DescriptionFlags) Add

func (d *DescriptionFlags) Add(cmd *cobra.Command)

Add registers the flags on cmd.

func (*DescriptionFlags) Check

func (d *DescriptionFlags) Check(f *cmdutil.Factory, cmd *cobra.Command) error

Check validates the flags after parsing.

func (*DescriptionFlags) Given

func (d *DescriptionFlags) Given() bool

Given reports whether any description source was given.

func (*DescriptionFlags) Read

func (d *DescriptionFlags) Read(f *cmdutil.Factory, initial string) (string, error)

Read returns the description from the chosen source; the editor starts with initial.

type FieldAssign

type FieldAssign struct{ Name, Value string }

FieldAssign is one --field "Name=Value".

func ParseFieldFlags

func ParseFieldFlags(raw []string) ([]FieldAssign, error)

ParseFieldFlags parses --field values.

type FieldWriter

type FieldWriter struct {
	Client  *transport.Client
	Project adapter.ProjectInfo
	Zone    *time.Location
	// contains filtered or unexported fields
}

FieldWriter encodes custom field values for one project. It reads the project's field definitions and the current user at most once.

func (*FieldWriter) Encode

func (w *FieldWriter) Encode(ctx context.Context, assigns []FieldAssign) (rest []map[string]any, commands []string, err error)

Encode turns assignments into IssueCustomField values for the REST API and commands for the fields written by command.

type Issue

type Issue struct {
	adapter.Issue
	Host     hosts.Host
	Comments []adapter.Comment
}

Issue exports an adapter.Issue under the --json field names.

func (Issue) ExportData

func (i Issue) ExportData(fields []string) map[string]any

type Ref

type Ref struct {
	ID string
	// ServiceURL is set when the issue was given as a URL.
	ServiceURL string
}

Ref is an issue named on the command line.

func ParseRef

func ParseRef(arg string) (Ref, error)

ParseRef accepts a readable ID (APP-123), a database ID (2-1234) or an issue URL such as https://acme.youtrack.cloud/issue/APP-123/some-slug.

Jump to

Keyboard shortcuts

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