Skip to content

Commit

Permalink
add -c flag for initial pipeline command
Browse files Browse the repository at this point in the history
Fixes #11
  • Loading branch information
akavel committed Oct 29, 2020
1 parent 5dc341c commit 3a63622
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions up.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var (
debugMode = pflag.Bool("debug", false, "debug mode")
noColors = pflag.Bool("no-colors", false, "disable interface colors")
shellFlag = pflag.StringArrayP("exec", "e", nil, "`command` to pass $PIPELINE through; use multiple times to pass multi-word command; defaults to '-e=$SHELL -e=-c'")
initialCmd = pflag.StringP("pipeline", "c", "", "initial command to use as $PIPELINE - editable later")
)

func main() {
Expand Down Expand Up @@ -125,7 +126,7 @@ func main() {
var (
// The top line of the TUI is an editable command, which will be used
// as a pipeline for data we read from stdin
commandEditor = NewEditor("| ")
commandEditor = NewEditor("| ", *initialCmd)
// The rest of the screen is a view of the results of the command
commandOutput = BufView{}
// Sometimes, a message may be displayed at the bottom of the screen, with help or other info
Expand Down Expand Up @@ -281,8 +282,14 @@ func die(message string) {
os.Exit(1)
}

func NewEditor(prompt string) *Editor {
return &Editor{prompt: []rune(prompt)}
func NewEditor(prompt, value string) *Editor {
v := []rune(value)
return &Editor{
prompt: []rune(prompt),
value: v,
cursor: len(v),
lastw: len(v),
}
}

type Editor struct {
Expand Down

0 comments on commit 3a63622

Please sign in to comment.