adapters/editor
import "go-cli-template/internal/adapters/editor"Index
- func IsEmacs(command string) bool
- func IsNano(command string) bool
- func IsVSCode(command string) bool
- func IsVim(command string) bool
- func OpenEmacsAtLine(command, path string, line int) error
- func OpenNanoAtLine(command, path string, line int) error
- func OpenVSCodeAtLine(command, path string, line int) error
- func OpenVimAtEnd(command, path string) error
- func OpenVimAtLine(command, path string, line int) error
- func OpenVimInsert(command, path string, line int) error
- func ResolveCommand(command string) string
- type Adapter
func IsEmacs
func IsEmacs(command string) boolIsEmacs checks if the command is emacs.
func IsNano
func IsNano(command string) boolIsNano checks if the command is nano.
func IsVSCode
func IsVSCode(command string) boolIsVSCode checks if the command is a VSCode-based editor.
func IsVim
func IsVim(command string) boolIsVim checks if the command is a vim-based editor.
func OpenEmacsAtLine
func OpenEmacsAtLine(command, path string, line int) errorOpenEmacsAtLine opens emacs at a specific line.
func OpenNanoAtLine
func OpenNanoAtLine(command, path string, line int) errorOpenNanoAtLine opens nano at a specific line.
func OpenVSCodeAtLine
func OpenVSCodeAtLine(command, path string, line int) errorOpenVSCodeAtLine opens VSCode at a specific line.
func OpenVimAtEnd
func OpenVimAtEnd(command, path string) errorOpenVimAtEnd opens vim at the end of the file.
func OpenVimAtLine
func OpenVimAtLine(command, path string, line int) errorOpenVimAtLine opens vim at a specific line.
func OpenVimInsert
func OpenVimInsert(command, path string, line int) errorOpenVimInsert opens vim at a specific line in insert mode.
func ResolveCommand
func ResolveCommand(command string) stringResolveCommand 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) *AdapterNew returns an editor adapter using the given command.
func (Adapter) Open
func (a Adapter) Open(path string) errorOpen launches the editor with the provided file path.
func (Adapter) OpenAtEnd
func (a Adapter) OpenAtEnd(path string) errorOpenAtEnd opens a file and positions the cursor at the end when supported.
func (Adapter) OpenAtLine
func (a Adapter) OpenAtLine(path string, line int) errorOpenAtLine opens a file at a specific line number.
Source
See internal/adapters/editor/ for implementation details.