2018-01-03 07:04:48 +01:00
|
|
|
// Copyright 2018 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
|
2018-01-30 05:34:00 +01:00
|
|
|
"github.com/miniflux/miniflux/logger"
|
|
|
|
|
2018-01-03 07:04:48 +01:00
|
|
|
"github.com/miniflux/miniflux/config"
|
|
|
|
"github.com/miniflux/miniflux/daemon"
|
|
|
|
"github.com/miniflux/miniflux/storage"
|
|
|
|
"github.com/miniflux/miniflux/version"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Parse parses command line arguments.
|
|
|
|
func Parse() {
|
|
|
|
flagInfo := flag.Bool("info", false, "Show application information")
|
|
|
|
flagVersion := flag.Bool("version", false, "Show application version")
|
|
|
|
flagMigrate := flag.Bool("migrate", false, "Migrate database schema")
|
|
|
|
flagFlushSessions := flag.Bool("flush-sessions", false, "Flush all sessions (disconnect users)")
|
|
|
|
flagCreateAdmin := flag.Bool("create-admin", false, "Create admin user")
|
2018-01-03 07:18:24 +01:00
|
|
|
flagResetPassword := flag.Bool("reset-password", false, "Reset user password")
|
2018-01-30 05:34:00 +01:00
|
|
|
flagDebugMode := flag.Bool("debug", false, "Enable debug mode (more verbose output)")
|
2018-01-03 07:04:48 +01:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
cfg := config.NewConfig()
|
|
|
|
store := storage.NewStorage(
|
2018-01-16 03:08:30 +01:00
|
|
|
cfg.DatabaseURL(),
|
|
|
|
cfg.DatabaseMaxConnections(),
|
2018-01-03 07:04:48 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if *flagInfo {
|
|
|
|
info()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if *flagVersion {
|
|
|
|
fmt.Println(version.Version)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if *flagMigrate {
|
|
|
|
store.Migrate()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if *flagFlushSessions {
|
|
|
|
flushSessions(store)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if *flagCreateAdmin {
|
|
|
|
createAdmin(store)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-01-03 07:18:24 +01:00
|
|
|
if *flagResetPassword {
|
|
|
|
resetPassword(store)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-01-30 05:54:38 +01:00
|
|
|
if *flagDebugMode || cfg.HasDebugMode() {
|
2018-01-30 05:34:00 +01:00
|
|
|
logger.EnableDebug()
|
|
|
|
}
|
|
|
|
|
2018-01-03 07:04:48 +01:00
|
|
|
daemon.Run(cfg, store)
|
|
|
|
}
|