Skip to content

Commit

Permalink
add(prompt): #2 - recursive prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-delaloy committed Oct 15, 2021
1 parent c15333f commit 311c1ea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

setup-env: ## Copy sample files
bash scripts/setup.sh
bash scripts/make/setup.sh

run: ## Up the docker-compose without cache or orphans
go run cmd/flamin-go/main.go
Expand Down
23 changes: 16 additions & 7 deletions cmd/flamin-go/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"strings"
Expand All @@ -14,15 +16,18 @@ import (

func execAction(file string) {
pwd, _ := os.Getwd()
actionFile := fmt.Sprintf("%s/scripts/%s.sh", pwd, file)
cmd := exec.Command("/bin/bash", actionFile)

cmd, err := exec.Command("/bin/bash", fmt.Sprintf("%s/scripts/%s.sh", pwd, file)).Output()
fmt.Print(chalk.Green, "Starting...", chalk.Reset)
helpers.ExitOnError("sh", err)
output := string(cmd)
fmt.Print(output)
}
var stdoutBuf, stderrBuf bytes.Buffer
cmd.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
cmd.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)

func main() {
err := cmd.Run()
helpers.ExitOnError("cmd.Run() failed with", err)

}
func run() {
fmt.Print("\033[H\033[2J")

searcher := func(input string, index int) bool {
Expand Down Expand Up @@ -75,5 +80,9 @@ func main() {
helpers.ExitOnError("confirmPrompt failed:", err)
if result == "" || result == "Y" || result == "y" {
execAction(action.Exec)
run()
}
}
func main() {
run()
}
2 changes: 1 addition & 1 deletion internal/core/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var Tasks = []Task{
{
Name: "install",
Description: "install all apt packages from cfg.sh",
Exec: "apt/update",
Exec: "apt/install",
},
{
Name: "update",
Expand Down

0 comments on commit 311c1ea

Please sign in to comment.