added iniflags to support config files
This commit is contained in:
parent
049ccd785b
commit
6472eeba37
@ -1,19 +1,18 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/vharitonsky/iniflags"
|
||||||
"haefelfinger.net/piwigo/DirectoriesToAlbums/internal/app"
|
"haefelfinger.net/piwigo/DirectoriesToAlbums/internal/app"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
iniflags.Parse()
|
||||||
rootPath := flag.Arg(0)
|
|
||||||
|
|
||||||
InitializeLog()
|
InitializeLog()
|
||||||
|
|
||||||
app.Run(rootPath)
|
app.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeLog() {
|
func InitializeLog() {
|
||||||
|
7
configs/defaultConfig.ini
Normal file
7
configs/defaultConfig.ini
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
allowMissingConfig = false # Don't terminate the app if the ini file cannot be read.
|
||||||
|
allowUnknownFlags = false # Don't terminate the app if ini file contains unknown flags.
|
||||||
|
configUpdateInterval = 0s # Update interval for re-reading config file set via -config flag. Zero disables config file re-reading.
|
||||||
|
imagesRootPath = # This is the images root path that should be mirrored to piwigo.
|
||||||
|
piwigoPassword = # This is password to the given username.
|
||||||
|
piwigoUrl = # The root url to your piwigo installation.
|
||||||
|
piwigoUser = # The username to use during sync.
|
@ -1,13 +1,21 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/localFileStructure"
|
"haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/localFileStructure"
|
||||||
"haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo/authentication"
|
"haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo/authentication"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(rootPath string) {
|
var (
|
||||||
context := configureContext(rootPath)
|
imagesRootPath = flag.String("imagesRootPath", "", "This is the images root path that should be mirrored to piwigo.")
|
||||||
|
piwigoUrl = flag.String("piwigoUrl", "", "The root url to your piwigo installation.")
|
||||||
|
piwigoUser = flag.String("piwigoUser", "", "The username to use during sync.")
|
||||||
|
piwigoPassword = flag.String("piwigoPassword", "", "This is password to the given username.")
|
||||||
|
)
|
||||||
|
|
||||||
|
func Run() {
|
||||||
|
context := configureContext()
|
||||||
|
|
||||||
loginToPiwigoAndConfigureContext(context)
|
loginToPiwigoAndConfigureContext(context)
|
||||||
|
|
||||||
@ -54,18 +62,15 @@ func UploadImages() {
|
|||||||
logrus.Warnln("Uploading missing images (NotImplemented)")
|
logrus.Warnln("Uploading missing images (NotImplemented)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureContext(rootPath string) *AppContext {
|
func configureContext() *AppContext {
|
||||||
logrus.Infoln("Preparing application context and configuration")
|
logrus.Infoln("Preparing application context and configuration")
|
||||||
|
|
||||||
context := new(AppContext)
|
context := new(AppContext)
|
||||||
context.LocalRootPath = rootPath
|
context.LocalRootPath = *imagesRootPath
|
||||||
context.Piwigo = new(authentication.PiwigoContext)
|
context.Piwigo = new(authentication.PiwigoContext)
|
||||||
|
context.Piwigo.Url = *piwigoUrl
|
||||||
//TODO: Move this values to configuration files
|
context.Piwigo.Username = *piwigoUser
|
||||||
//No, these are not real credentials :-P
|
context.Piwigo.Password = *piwigoPassword
|
||||||
context.Piwigo.Url = "http://pictures.haefelfinger.net/ws.php?format=json"
|
|
||||||
context.Piwigo.Username = "admin"
|
|
||||||
context.Piwigo.Password = "asdf"
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user