Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions luci.config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

title = "Hello World!"
description = "Luci config hello world example."

[bash.run]
example = "echo Hello World!"

[zshell.run]
example = "echo Hello World!"

[bat.run]
example = "echo Hello World!"
34 changes: 6 additions & 28 deletions utils/exec.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package utils

import (
"bufio"
"fmt"
"log"
"os"
"os/exec"
"runtime"
"strings"
Expand Down Expand Up @@ -86,29 +84,9 @@ func execAction(action any) bool {
}

func execCmd(cmd *exec.Cmd) {
pipe, err := cmd.StdoutPipe()
if err != nil {
log.Fatal(err)
}
scanner := bufio.NewScanner(pipe)

err = cmd.Start()
if err != nil {
log.Fatal(err)
}

for scanner.Scan() {
m := scanner.Text()
fmt.Println(m)
}

if err := scanner.Err(); err != nil {
log.Fatal(err)
}

// Wait for the command to finish after reading all output
err = cmd.Wait()
if err != nil {
log.Fatal(err)
}
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Must(cmd.Start())
Must(cmd.Wait())
}
6 changes: 6 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ func GetShellType() types.ShellType {
return types.Unknown
}
}

func Must(err error) {
if err != nil {
panic(err)
}
}