Documentation
¶
Overview ¶
Package shared holds what the issue commands have in common: issue arguments, the --json field contract and issue URLs.
Index ¶
- Constants
- Variables
- func Attrs(jsonFields []string, extra ...string) []string
- func CheckFieldsApplied(ctx context.Context, c *transport.Client, id string, rest []map[string]any) error
- func CheckFiles(paths []string) ([]adapter.LocalFile, error)
- func CommentURL(host hosts.Host, issueID, commentID string) string
- func CompleteIssues(f *cmdutil.Factory, maxArgs int) cobra.CompletionFunc
- func CompleteProjects(f *cmdutil.Factory) cobra.CompletionFunc
- func FindProject(ctx context.Context, c *transport.Client, key string) (adapter.ProjectInfo, error)
- func InlineRefs(body string, paths []string) string
- func IssueURL(host hosts.Host, id string) string
- func NotFound(err error, id string, host hosts.Host) error
- func NotFoundf(apiErr *transport.APIError, format string, args ...any) error
- func ParsedCommands(cs []adapter.ParsedCommand) []map[string]any
- func ResolveTags(ctx context.Context, c *transport.Client, names []string) ([]adapter.Tag, error)
- func UseRefHost(f *cmdutil.Factory, ref Ref, sendsToken bool) error
- func UseRefHostForWrite(f *cmdutil.Factory, ref Ref) error
- func Zone(f *cmdutil.Factory) (*time.Location, error)
- type Attachment
- type DescriptionFlags
- type FieldAssign
- type FieldWriter
- type FieldsUnreadableError
- type Issue
- type Ref
Constants ¶
const AttachmentFieldsHelp = `` /* 260-byte string literal not displayed */
AttachmentFieldsHelp documents AttachmentFields for command help.
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. Without access
to the project settings, the field definitions come from the issue (edit) or
from an issue in the project (create). edit reads the issue back and fails
when a field did not take the new 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.
const IssueFieldsHelp = `` /* 824-byte string literal not displayed */
IssueFieldsHelp documents IssueFields for command help.
Variables ¶
var AttachmentFields = []string{"name", "id", "size", "mimeType", "created", "author", "commentId"}
AttachmentFields lists the --json fields of an issue's attachments.
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 ¶
Attrs returns the adapter attributes needed for the requested --json fields plus extra.
func CheckFieldsApplied ¶ added in v0.5.3
func CheckFieldsApplied(ctx context.Context, c *transport.Client, id string, rest []map[string]any) error
CheckFieldsApplied reads issue id back and fails, naming the fields, when a custom field written through the REST API (rest, from Encode) does not hold the value written: YouTrack can accept a write that a workflow or a permission then leaves unapplied.
func CheckFiles ¶ added in v0.5.0
CheckFiles checks files to upload, all before any request, so a missing or unreadable file posts nothing. A regular file is not read into memory: it must open and read, and its size and media type, guessed from its name or its first bytes, are recorded so the upload can stream it. A pipe, such as a FIFO or the /dev/fd/N of a shell's process substitution, can be read only once, so it is read in full here. Anything else, such as a directory or a device, is refused. Each attachment is named after its file's base name, which must be unique: a comment refers to it by that name.
func CommentURL ¶
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 ¶
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 InlineRefs ¶ added in v0.4.0
InlineRefs rewrites Markdown links and images in body that point at an attached file by the path it was given, such as , to its attachment name (), which YouTrack resolves to the attachment.
func NotFound ¶
NotFound turns a 404 for issue id into a clear message. When more than one host is logged in, it also says why host was chosen and which hosts to try.
func NotFoundf ¶ added in v0.5.2
NotFoundf formats a not-found message, followed by the 404's host hint, and keeps the 404 underneath, so Factory.WithIssueHost still sees it.
func ParsedCommands ¶
func ParsedCommands(cs []adapter.ParsedCommand) []map[string]any
ParsedCommands exports YouTrack's parse of a command for --json.
func ResolveTags ¶
ResolveTags finds the tags called names, exactly or else ignoring case.
func UseRefHost ¶
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 ¶
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.
Types ¶
type Attachment ¶ added in v0.5.4
type Attachment struct{ adapter.IssueAttachment }
Attachment is an issue attachment for --json output.
func (Attachment) ExportData ¶ added in v0.5.4
func (a Attachment) ExportData(fields []string) map[string]any
ExportData implements output.Exportable.
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) Given ¶
func (d *DescriptionFlags) Given() bool
Given reports whether any description source was given.
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
// IssueID is the issue being edited; empty when creating one.
IssueID string
// 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 FieldsUnreadableError ¶ added in v0.5.3
type FieldsUnreadableError struct{ Project, IssueID string }
FieldsUnreadableError says the project's custom fields could not be read from any source, so --field cannot be checked or encoded.
func (*FieldsUnreadableError) Error ¶ added in v0.5.3
func (e *FieldsUnreadableError) Error() string
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 ¶
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 or https://acme.youtrack.cloud/projects/APP/issues/APP-123, with any query or fragment.