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 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 NotFoundElsewhere(ctx context.Context, f *cmdutil.Factory, err error, id string, host hosts.Host) error
- func ParsedCommands(cs []adapter.ParsedCommand) []map[string]any
- func ReadFiles(paths []string) ([]adapter.File, error)
- 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 DescriptionFlags
- type FieldAssign
- type FieldWriter
- type Issue
- type Ref
Constants ¶
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.
const IssueFieldsHelp = `` /* 824-byte string literal not displayed */
IssueFieldsHelp documents IssueFields for command help.
Variables ¶
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 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 NotFoundElsewhere ¶ added in v0.4.0
func NotFoundElsewhere(ctx context.Context, f *cmdutil.Factory, err error, id string, host hosts.Host) error
NotFoundElsewhere is NotFound, and when host is only the default host (no --host, issue URL, YTRACK_HOST or folder path picked it), it looks for the issue on the other logged-in hosts, with their stored tokens, and names the first one that has it.
func ParsedCommands ¶
func ParsedCommands(cs []adapter.ParsedCommand) []map[string]any
ParsedCommands exports YouTrack's parse of a command for --json.
func ReadFiles ¶ added in v0.4.0
ReadFiles reads files to attach, all before any request, so a missing or unreadable file posts nothing. Each attachment is named after its file's base name, which must be unique: a comment refers to it by that name.
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 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
// 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 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.