Add CLI flag to only show config UI and skip the slideshow display (so you can config & auto-reload the main piframe ui over ssh and similar

This commit is contained in:
KemoNine 2020-09-02 23:56:25 -04:00
parent e2bce8d442
commit 712f7c7a45
1 changed files with 21 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"log"
"os"
@ -8,6 +9,8 @@ import (
"github.com/knadh/koanf/parsers/toml"
"github.com/knadh/koanf/providers/confmap"
"github.com/knadh/koanf/providers/file"
"github.com/knadh/koanf/providers/posflag"
flag "github.com/spf13/pflag"
//"git.kemonine.info/PiFrame/ui"
)
@ -29,6 +32,17 @@ const (
)
func main() {
// Command line flag handler
f := flag.NewFlagSet("config", flag.ContinueOnError)
f.Usage = func() {
fmt.Println(f.FlagUsages())
os.Exit(0)
}
// Command line flags
f.Bool("config-ui-only", false, "Only show the config UI, NOT the slideshow")
// Process command line flags into handler
f.Parse(os.Args[1:])
// Main config variable
var pfConfig = koanf.New(".")
@ -41,6 +55,7 @@ func main() {
CONFIG_KEY_ALBUMS_SELECTED: []string{DEFAULT_ALBUM_SELECTED},
}, "."), nil)
// Bring in /etc/defaults/pf.toml if it exists
_, err := os.Stat(CONFIG_FILE_PATH)
if err != nil {
if os.IsNotExist(err) {
@ -52,6 +67,11 @@ func main() {
}
}
// Process command line flags
if err := pfConfig.Load(posflag.Provider(f, ".", pfConfig), nil); err != nil {
log.Fatalf("Error loading command line flags : %v", err)
}
// slideshowDuration := pfConfig.Duration(CONFIG_KEY_SLIDESHOW_DURATION)
// hdmiOff := pfConfig.String(CONFIG_KEY_HDMI_OFF)
// hdmiOn := pfConfig.String(CONFIG_KEY_HDMI_ON)