diff --git a/cmd.go b/cmd.go index 63614c64..929b333a 100644 --- a/cmd.go +++ b/cmd.go @@ -4,9 +4,7 @@ import ( "bufio" "fmt" "os" - "os/exec" "strconv" - "time" ) var cmdArgs = makeArguments() @@ -118,31 +116,6 @@ If no arguments are provided 'yay -Syu' will be performed If no operation is provided -Y will be assumed`) } -func sudoLoopBackground() { - updateSudo() - go sudoLoop() -} - -func sudoLoop() { - for { - updateSudo() - time.Sleep(298 * time.Second) - } -} - -func updateSudo() { - for { - cmd := exec.Command("sudo", "-v") - cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr - err := cmd.Run() - if err != nil { - fmt.Println(err) - } else { - break - } - } -} - func handleCmd() (err error) { for option, value := range cmdArgs.options { if handleConfig(option, value) { diff --git a/exec.go b/exec.go index f97cbab9..b7249ccf 100644 --- a/exec.go +++ b/exec.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "strings" + "time" ) func show(cmd *exec.Cmd) error { @@ -29,6 +30,29 @@ func capture(cmd *exec.Cmd) (string, string, error) { return stdout, stderr, err } +func sudoLoopBackground() { + updateSudo() + go sudoLoop() +} + +func sudoLoop() { + for { + updateSudo() + time.Sleep(298 * time.Second) + } +} + +func updateSudo() { + for { + err := show(exec.Command("sudo", "-v")) + if err != nil { + fmt.Println(err) + } else { + break + } + } +} + func passToPacman(args *arguments) *exec.Cmd { argArr := make([]string, 0)