parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBackquoteNotClosed         = errors.New("backquote not closed")
	ErrTooManySessionsInBackquote = errors.New("too many sessions in backquote")
	ErrNoRedirectTarget           = errors.New("no redirect target")
	ErrNoProcessAfterPipe         = errors.New("no process after pipe")
)

Functions

func ParseCommandStr

func ParseCommandStr(cmdStr string) ([][]*Session, error)

Types

type Fragment

type Fragment struct {
	Term     string
	Sessions []*Session
	Texts    []string
}

Fragment represents small piece of word of commandline string.

If the word has back quote, it returns sessions, texts.

"current branch is `git branch` and current commit is `git rev-parse HEAD`."

[]Tests{"current branch is ", " and current commit is ", "."}
[]Sessions{{"git", "branch"}, {"git", "rev-parse", "HEAD"}}

type Separator

type Separator int
const (
	Semicolon  Separator = 0 // ;
	LogicalOr  Separator = 1 // ||
	LogicalAnd Separator = 2 // &&
)

type Session

type Session struct {
	Fragments    []Fragment
	Stdin        string
	Stdout       string
	StdoutAppend bool
	Stderr       string
	StderrAppend bool
	Separator    Separator
}

func (Session) GetCommand

func (s Session) GetCommand() (cmd string, args []string)

Jump to

Keyboard shortcuts

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