Created
January 26, 2023 09:50
-
-
Save bontusss/db22a76e28569c15daa363c2c40bdf47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
"os/exec" | |
) | |
var cmdChain = []*exec.Cmd{ | |
exec.Command("lib/synonyms"), | |
exec.Command("lib/sprinkle"), | |
exec.Command("lib/coolify"), | |
exec.Command("lib/domainify"), | |
exec.Command("lib/available"), | |
} | |
func main() { | |
cmdChain[0].Stdin = os.Stdin | |
cmdChain[len(cmdChain)-1].Stdout = os.Stdout | |
for i := 0; i < len(cmdChain)-1; i++ { | |
thisCmd := cmdChain[i] | |
nextCmd := cmdChain[i+1] | |
stdout, err := thisCmd.StdoutPipe() | |
if err != nil { | |
log.Fatalln(err) | |
} | |
nextCmd.Stdin = stdout | |
} | |
for _, cmd := range cmdChain { | |
if err := cmd.Start(); err != nil { | |
log.Fatalln(err) | |
} else { | |
defer cmd.Process.Kill() | |
} | |
} | |
for _, cmd := range cmdChain { | |
if err := cmd.Wait(); err != nil { | |
log.Fatalln(err) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment