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

View file

@ -5,29 +5,15 @@ import (
"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 main() {
user := os.Getenv("PHOTOPRISM_USER")
if user == "" {
halt(1, "Missing PHOTOPRISM_USER")
uuid := os.Getenv("PHOTOPRISM_ID")
if uuid == "" {
halt(2, "Missing PHOTOPRISM_UUID")
}
pass := os.Getenv("PHOTOPRISM_PASS")
if pass == "" {
halt(2, "Missing PHOTOPRISM_PASS")
}
login := photoprism.NewClientAuthLogin("username", "password")
photoclient := photoprism.New(login)
photo, err := photoclient.V1().GetPhoto("123")
client := photoprism.New(auth())
photo, err := client.V1().GetPhoto(uuid)
if err != nil {
halt(3, "Error fetching photo: %v", err)
}