Improve command package comments (#251)
This commit is contained in:
parent
89e44def83
commit
4fe5aaaccd
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
This package contains commands and flags used by the photoprism application.
|
Package commands contains commands and flags used by the photoprism application.
|
||||||
|
|
||||||
Additional information concerning the command-line interface can be found in our Developer Guide:
|
Additional information concerning the command-line interface can be found in our Developer Guide:
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ import (
|
||||||
|
|
||||||
var log = event.Log
|
var log = event.Log
|
||||||
|
|
||||||
|
// chilAlreadyRunning test if a .pid file at filePath is a running proccess.
|
||||||
|
// it returns the pid value and the running status (true or false).
|
||||||
func childAlreadyRunning(filePath string) (pid int, running bool) {
|
func childAlreadyRunning(filePath string) (pid int, running bool) {
|
||||||
if !fs.FileExists(filePath) {
|
if !fs.FileExists(filePath) {
|
||||||
return pid, false
|
return pid, false
|
||||||
|
|
|
@ -7,13 +7,14 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Prints current configuration
|
// ConfigCommand is used to register the display config cli command
|
||||||
var ConfigCommand = cli.Command{
|
var ConfigCommand = cli.Command{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Usage: "Displays global configuration values",
|
Usage: "Displays global configuration values",
|
||||||
Action: configAction,
|
Action: configAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// configAction prints current configuration
|
||||||
func configAction(ctx *cli.Context) error {
|
func configAction(ctx *cli.Context) error {
|
||||||
conf := config.NewConfig(ctx)
|
conf := config.NewConfig(ctx)
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,14 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Converts RAW files to JPEG images, if no JPEG already exists
|
// ConvertCommand is used to register the convert cli command
|
||||||
var ConvertCommand = cli.Command{
|
var ConvertCommand = cli.Command{
|
||||||
Name: "convert",
|
Name: "convert",
|
||||||
Usage: "Converts originals in other formats to JPEG",
|
Usage: "Converts originals in other formats to JPEG",
|
||||||
Action: convertAction,
|
Action: convertAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convertAction converts RAW files to JPEG images, if no JPEG already exists
|
||||||
func convertAction(ctx *cli.Context) error {
|
func convertAction(ctx *cli.Context) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CopyCommand is used to register the copy cli command
|
||||||
var CopyCommand = cli.Command{
|
var CopyCommand = cli.Command{
|
||||||
Name: "copy",
|
Name: "copy",
|
||||||
Aliases: []string{"cp"},
|
Aliases: []string{"cp"},
|
||||||
|
@ -21,12 +22,13 @@ var CopyCommand = cli.Command{
|
||||||
Action: copyAction,
|
Action: copyAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copies photos to originals path.
|
// copyAction copies photos to originals path. Default import path is used if no path argument provided
|
||||||
func copyAction(ctx *cli.Context) error {
|
func copyAction(ctx *cli.Context) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
conf := config.NewConfig(ctx)
|
conf := config.NewConfig(ctx)
|
||||||
|
|
||||||
|
// very if copy directory exist and is writable
|
||||||
if conf.ReadOnly() {
|
if conf.ReadOnly() {
|
||||||
return config.ErrReadOnly
|
return config.ErrReadOnly
|
||||||
}
|
}
|
||||||
|
@ -43,6 +45,7 @@ func copyAction(ctx *cli.Context) error {
|
||||||
|
|
||||||
conf.MigrateDb()
|
conf.MigrateDb()
|
||||||
|
|
||||||
|
// get cli first argument
|
||||||
sourcePath := strings.TrimSpace(ctx.Args().First())
|
sourcePath := strings.TrimSpace(ctx.Args().First())
|
||||||
|
|
||||||
if sourcePath == "" {
|
if sourcePath == "" {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ImportCommand is used to register the import cli command
|
||||||
var ImportCommand = cli.Command{
|
var ImportCommand = cli.Command{
|
||||||
Name: "import",
|
Name: "import",
|
||||||
Aliases: []string{"mv"},
|
Aliases: []string{"mv"},
|
||||||
|
@ -21,12 +22,13 @@ var ImportCommand = cli.Command{
|
||||||
Action: importAction,
|
Action: importAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moves photos to originals path.
|
// importAction moves photos to originals path. Default import path is used if no path argument provided
|
||||||
func importAction(ctx *cli.Context) error {
|
func importAction(ctx *cli.Context) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
conf := config.NewConfig(ctx)
|
conf := config.NewConfig(ctx)
|
||||||
|
|
||||||
|
// very if copy directory exist and is writable
|
||||||
if conf.ReadOnly() {
|
if conf.ReadOnly() {
|
||||||
return config.ErrReadOnly
|
return config.ErrReadOnly
|
||||||
}
|
}
|
||||||
|
@ -43,6 +45,7 @@ func importAction(ctx *cli.Context) error {
|
||||||
|
|
||||||
conf.MigrateDb()
|
conf.MigrateDb()
|
||||||
|
|
||||||
|
// get cli first argument
|
||||||
sourcePath := strings.TrimSpace(ctx.Args().First())
|
sourcePath := strings.TrimSpace(ctx.Args().First())
|
||||||
|
|
||||||
if sourcePath == "" {
|
if sourcePath == "" {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// indexes all photos in originals directory (photo library)
|
// IndexCommand is used to register the index cli command
|
||||||
var IndexCommand = cli.Command{
|
var IndexCommand = cli.Command{
|
||||||
Name: "index",
|
Name: "index",
|
||||||
Usage: "Indexes media files in originals path",
|
Usage: "Indexes media files in originals path",
|
||||||
|
@ -26,6 +26,7 @@ var indexFlags = []cli.Flag{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// indexAction indexes all photos in originals directory (photo library)
|
||||||
func indexAction(ctx *cli.Context) error {
|
func indexAction(ctx *cli.Context) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,14 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Automatically migrates / initializes database
|
// MigrateCommand is used to register the migrate cli command
|
||||||
var MigrateCommand = cli.Command{
|
var MigrateCommand = cli.Command{
|
||||||
Name: "migrate",
|
Name: "migrate",
|
||||||
Usage: "Automatically initializes and migrates the database",
|
Usage: "Automatically initializes and migrates the database",
|
||||||
Action: migrateAction,
|
Action: migrateAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// migrateAction automatically migrates or initializes database
|
||||||
func migrateAction(ctx *cli.Context) error {
|
func migrateAction(ctx *cli.Context) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Starts web server (user interface)
|
// StartCommand is used to register the start cli command
|
||||||
var StartCommand = cli.Command{
|
var StartCommand = cli.Command{
|
||||||
Name: "start",
|
Name: "start",
|
||||||
Aliases: []string{"up"},
|
Aliases: []string{"up"},
|
||||||
|
@ -37,6 +37,7 @@ var startFlags = []cli.Flag{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// startAction start the web server and initializes the daemon
|
||||||
func startAction(ctx *cli.Context) error {
|
func startAction(ctx *cli.Context) error {
|
||||||
conf := config.NewConfig(ctx)
|
conf := config.NewConfig(ctx)
|
||||||
|
|
||||||
|
@ -74,9 +75,10 @@ func startAction(ctx *cli.Context) error {
|
||||||
if err := conf.Init(cctx); err != nil {
|
if err := conf.Init(cctx); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
// initialize the database
|
||||||
conf.MigrateDb()
|
conf.MigrateDb()
|
||||||
|
|
||||||
|
// check if daemon is running, if not initialize the daemon
|
||||||
dctx := new(daemon.Context)
|
dctx := new(daemon.Context)
|
||||||
dctx.LogFileName = conf.LogFilename()
|
dctx.LogFileName = conf.LogFilename()
|
||||||
dctx.PidFileName = conf.PIDFilename()
|
dctx.PidFileName = conf.PIDFilename()
|
||||||
|
@ -110,8 +112,10 @@ func startAction(ctx *cli.Context) error {
|
||||||
log.Infof("read-only mode enabled")
|
log.Infof("read-only mode enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start web server
|
||||||
go server.Start(cctx, conf)
|
go server.Start(cctx, conf)
|
||||||
|
|
||||||
|
// set up proper shutdown of daemon and web server
|
||||||
quit := make(chan os.Signal)
|
quit := make(chan os.Signal)
|
||||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StopCommand stops the daemon if running.
|
// StopCommand is used to register the stop cli command
|
||||||
var StopCommand = cli.Command{
|
var StopCommand = cli.Command{
|
||||||
Name: "stop",
|
Name: "stop",
|
||||||
Aliases: []string{"down"},
|
Aliases: []string{"down"},
|
||||||
|
@ -16,6 +16,7 @@ var StopCommand = cli.Command{
|
||||||
Action: stopAction,
|
Action: stopAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stopAction stops the daemon if it is running.
|
||||||
func stopAction(ctx *cli.Context) error {
|
func stopAction(ctx *cli.Context) error {
|
||||||
conf := config.NewConfig(ctx)
|
conf := config.NewConfig(ctx)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pre-renders thumbnails
|
// ThumbsCommand is used to register the thumbs cli command
|
||||||
var ThumbsCommand = cli.Command{
|
var ThumbsCommand = cli.Command{
|
||||||
Name: "thumbs",
|
Name: "thumbs",
|
||||||
Usage: "Pre-renders thumbnails to boost performance",
|
Usage: "Pre-renders thumbnails to boost performance",
|
||||||
|
@ -21,6 +21,7 @@ var ThumbsCommand = cli.Command{
|
||||||
Action: thumbsAction,
|
Action: thumbsAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// thumbsAction pre-render the thumbnails
|
||||||
func thumbsAction(ctx *cli.Context) error {
|
func thumbsAction(ctx *cli.Context) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,14 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Prints current version
|
// VersionCommand is used to register the version cli command
|
||||||
var VersionCommand = cli.Command{
|
var VersionCommand = cli.Command{
|
||||||
Name: "version",
|
Name: "version",
|
||||||
Usage: "Shows version information",
|
Usage: "Shows version information",
|
||||||
Action: versionAction,
|
Action: versionAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// versionAction prints the current version
|
||||||
func versionAction(ctx *cli.Context) error {
|
func versionAction(ctx *cli.Context) error {
|
||||||
conf := config.NewConfig(ctx)
|
conf := config.NewConfig(ctx)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue