~rek2/goTootRamdonVideo

66c5dcf353ff2e6efc55b7c5d804a57ec22444bb — rek2 2 years ago 44fefca
add function to parse credentials by a command in the ini config to a external app like gopass or pass
1 files changed, 18 insertions(+), 0 deletions(-)

M main.go
M main.go => main.go +18 -0
@@ 6,6 6,8 @@ import (
	"log"
	"math/rand"
	"os"
	"os/exec"
	"strings"
	"time"

	"github.com/mattn/go-mastodon"


@@ 91,3 93,19 @@ func createTheToot(toot theFeed) mastodon.Toot {
	}
	return theToot
}

func parseCredentials(command string) (string, error) {

	if command == "" {
		return "", nil
	}
	cmd := exec.Command("sh", "-c", command)
	cmd.Stdin = os.Stdin
	output, err := cmd.Output()
	if err != nil {
		log.Fatal(err)
	}
	sec := strings.TrimSpace(string(output))

	return sec, nil
}