summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Czapliński <czapkofan@gmail.com>2020-10-29 20:29:36 +0100
committerMateusz Czapliński <czapkofan@gmail.com>2020-10-29 21:54:38 +0100
commit3a636226c8b0de865ca1db365fb135283b2e42b4 (patch)
tree45f259cc94d9b13cf1078df11815296c7caee045
parent5dc341c6bbbd842cd101c9c0e80ad283fac261f8 (diff)
add -c flag for initial pipeline command
Fixes #11
-rw-r--r--up.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/up.go b/up.go
index c41703c..751ea93 100644
--- a/up.go
+++ b/up.go
@@ -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() {
@@ -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
@@ -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 {