editor

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditMarkdown

func EditMarkdown(ctx context.Context, issueKey, fieldName, markdown, editorCommand string) (string, error)

EditMarkdown writes a temp file, spawns the configured editor, and reads the edited content back. The temp file is preserved on every error path (per kubectl's pattern) so the user can recover in-flight edits — the path is named in the error message.

A sub-second editor exit combined with byte-identical content trips the non-blocking-spawn safety check: that's the signature of `EDITOR=code` (without --wait) returning before VS Code has finished opening the buffer. Treating it as success would race the parent's cleanup against the editor's save, causing the strikethrough-on- filename + silent-data-loss bug.

func ReadMarkdown

func ReadMarkdown(path string) (string, error)

func Resolve

func Resolve(configured string) string

Resolve returns the editor command to launch, given a configured editor (typically pulled from profile.editor or global config.editor).

Precedence:

JIRA_EDITOR → configured → $EDITOR → $VISUAL → "vi"

JIRA_EDITOR is the per-invocation override; configured is the user's pinned preference in jira-cli config; $EDITOR/$VISUAL are the platform defaults; "vi" is the last-resort fallback. An empty value at any level falls through to the next.

func ResolveEditor

func ResolveEditor() string

ResolveEditor is the no-arg variant for callers that don't have access to the config layer. Equivalent to Resolve("").

func RoundTripADF

func RoundTripADF(ctx context.Context, opts RoundTripADFOptions) (adf.Document, []adf.Warning, error)

RoundTripADF takes an ADF document, renders it to GFM Markdown for the editor buffer, preserves any non-Markdown-representable subtrees as fenced opaque blocks, launches the editor, parses the edited Markdown back, reconstitutes the opaques, and returns the resulting Document plus any structured warnings emitted along the way.

func Run

func Run(ctx context.Context, editorCommand, path string) error

func WriteTemp

func WriteTemp(issueKey, fieldName, markdown string) (string, error)

Types

type RoundTripADFOptions

type RoundTripADFOptions struct {
	IssueKey  string
	FieldName string
	Document  adf.Document
	// EditCmd is the user's editor invocation (env-driven). Mutually
	// exclusive with EditFn — EditFn wins for tests.
	EditCmd string
	EditFn  func(ctx context.Context, path string) error
}

RoundTripADFOptions configures one external --edit cycle.

Jump to

Keyboard shortcuts

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