Skip to content

adapters/editor

import "go-cli-template/internal/adapters/editor"

Index

func IsEmacs

func IsEmacs(command string) bool

IsEmacs checks if the command is emacs.

func IsNano

func IsNano(command string) bool

IsNano checks if the command is nano.

func IsVSCode

func IsVSCode(command string) bool

IsVSCode checks if the command is a VSCode-based editor.

func IsVim

func IsVim(command string) bool

IsVim checks if the command is a vim-based editor.

func OpenEmacsAtLine

func OpenEmacsAtLine(command, path string, line int) error

OpenEmacsAtLine opens emacs at a specific line.

func OpenNanoAtLine

func OpenNanoAtLine(command, path string, line int) error

OpenNanoAtLine opens nano at a specific line.

func OpenVSCodeAtLine

func OpenVSCodeAtLine(command, path string, line int) error

OpenVSCodeAtLine opens VSCode at a specific line.

func OpenVimAtEnd

func OpenVimAtEnd(command, path string) error

OpenVimAtEnd opens vim at the end of the file.

func OpenVimAtLine

func OpenVimAtLine(command, path string, line int) error

OpenVimAtLine opens vim at a specific line.

func OpenVimInsert

func OpenVimInsert(command, path string, line int) error

OpenVimInsert opens vim at a specific line in insert mode.

func ResolveCommand

func ResolveCommand(command string) string

ResolveCommand resolves the editor command from config or environment.

type Adapter

Adapter launches the configured editor.

type Adapter struct {
Command string
}

func New

func New(command string) *Adapter

New returns an editor adapter using the given command.

func (Adapter) Open

func (a Adapter) Open(path string) error

Open launches the editor with the provided file path.

func (Adapter) OpenAtEnd

func (a Adapter) OpenAtEnd(path string) error

OpenAtEnd opens a file and positions the cursor at the end when supported.

func (Adapter) OpenAtLine

func (a Adapter) OpenAtLine(path string, line int) error

OpenAtLine opens a file at a specific line number.

Source

See internal/adapters/editor/ for implementation details.