Add command line flag to allow only running the config ui

This commit is contained in:
KemoNine 2020-09-03 00:24:26 -04:00
parent 712f7c7a45
commit ce9f53cb45
1 changed files with 17 additions and 4 deletions

View File

@ -11,7 +11,12 @@ import (
"github.com/knadh/koanf/providers/file" "github.com/knadh/koanf/providers/file"
"github.com/knadh/koanf/providers/posflag" "github.com/knadh/koanf/providers/posflag"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
//"git.kemonine.info/PiFrame/ui"
"git.kemonine.info/PiFrame/ui"
)
const (
CLI_FLAG_CONFIG_ONLY = "config-ui-only"
) )
const ( const (
@ -33,13 +38,18 @@ const (
func main() { func main() {
// Command line flag handler // Command line flag handler
f := flag.NewFlagSet("config", flag.ContinueOnError) f := flag.NewFlagSet("piframe", flag.ContinueOnError)
f.Usage = func() { f.Usage = func() {
fmt.Println(f.FlagUsages()) fmt.Println(f.FlagUsages())
os.Exit(0) os.Exit(0)
} }
// Command line flags // Command line flags
f.Bool("config-ui-only", false, "Only show the config UI, NOT the slideshow") f.Bool(CLI_FLAG_CONFIG_ONLY, false, "Only show the config UI, NOT the slideshow")
cliFlag := f.Lookup(CLI_FLAG_CONFIG_ONLY)
if cliFlag != nil {
log.Print("Could not find CLI_FLAG_CONFIG_ONLY")
cliFlag.NoOptDefVal = "true"
}
// Process command line flags into handler // Process command line flags into handler
f.Parse(os.Args[1:]) f.Parse(os.Args[1:])
@ -78,6 +88,9 @@ func main() {
// albumsRoot := pfConfig.String(CONFIG_KEY_ALBUMS_ROOT) // albumsRoot := pfConfig.String(CONFIG_KEY_ALBUMS_ROOT)
// albumsSelected := pfConfig.Strings(CONFIG_KEY_ALBUMS_SELECTED) // albumsSelected := pfConfig.Strings(CONFIG_KEY_ALBUMS_SELECTED)
//ui.Slideshow() if !pfConfig.Bool(CLI_FLAG_CONFIG_ONLY) {
ui.Slideshow()
}
//ui.ConfigGui() //ui.ConfigGui()
} }