Pushing changes for testing harness before my next meeting. Adding working exec library and sample code

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-02-03 11:00:11 -08:00
parent 95794522e0
commit b107d98a37
14 changed files with 313 additions and 19 deletions

30
examples/common.go Normal file
View file

@ -0,0 +1,30 @@
package main
import (
"fmt"
"os"
photoprism "github.com/kris-nova/client-go"
"github.com/kris-nova/logger"
)
// format string, a ...interface{}
func halt(code int, msg string, a ...interface{}) {
str := fmt.Sprintf(msg, a...)
logger.Critical(str)
os.Exit(code)
}
func auth() photoprism.ClientAuthenticator {
user := os.Getenv("PHOTOPRISM_USER")
if user == "" {
halt(1, "Missing PHOTOPRISM_USER")
}
pass := os.Getenv("PHOTOPRISM_PASS")
if pass == "" {
halt(2, "Missing PHOTOPRISM_PASS")
}
auth := photoprism.NewClientAuthLogin(user, pass)
return auth
}