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:
|
||||
|
||||
|
@ -18,6 +18,8 @@ import (
|
|||
|
||||
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) {
|
||||
if !fs.FileExists(filePath) {
|
||||
return pid, false
|
||||
|
|
|
@ -7,13 +7,14 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// Prints current configuration
|
||||
// ConfigCommand is used to register the display config cli command
|
||||
var ConfigCommand = cli.Command{
|
||||
Name: "config",
|
||||
Usage: "Displays global configuration values",
|
||||
Action: configAction,
|
||||
}
|
||||
|
||||
// configAction prints current configuration
|
||||
func configAction(ctx *cli.Context) error {
|
||||
conf := config.NewConfig(ctx)
|
||||
|
||||
|
|
|
@ -8,13 +8,14 @@ import (
|
|||
"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{
|
||||
Name: "convert",
|
||||
Usage: "Converts originals in other formats to JPEG",
|
||||
Action: convertAction,
|
||||
}
|
||||
|
||||
// convertAction converts RAW files to JPEG images, if no JPEG already exists
|
||||
func convertAction(ctx *cli.Context) error {
|
||||
start := time.Now()
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// CopyCommand is used to register the copy cli command
|
||||
var CopyCommand = cli.Command{
|
||||
Name: "copy",
|
||||
Aliases: []string{"cp"},
|
||||
|
@ -21,12 +22,13 @@ var CopyCommand = cli.Command{
|
|||
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 {
|
||||
start := time.Now()
|
||||
|
||||
conf := config.NewConfig(ctx)
|
||||
|
||||
// very if copy directory exist and is writable
|
||||
if conf.ReadOnly() {
|
||||
return config.ErrReadOnly
|
||||
}
|
||||
|
@ -43,6 +45,7 @@ func copyAction(ctx *cli.Context) error {
|
|||
|
||||
conf.MigrateDb()
|
||||
|
||||
// get cli first argument
|
||||
sourcePath := strings.TrimSpace(ctx.Args().First())
|
||||
|
||||
if sourcePath == "" {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// ImportCommand is used to register the import cli command
|
||||
var ImportCommand = cli.Command{
|
||||
Name: "import",
|
||||
Aliases: []string{"mv"},
|
||||
|
@ -21,12 +22,13 @@ var ImportCommand = cli.Command{
|
|||
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 {
|
||||
start := time.Now()
|
||||
|
||||
conf := config.NewConfig(ctx)
|
||||
|
||||
// very if copy directory exist and is writable
|
||||
if conf.ReadOnly() {
|
||||
return config.ErrReadOnly
|
||||
}
|
||||
|
@ -43,6 +45,7 @@ func importAction(ctx *cli.Context) error {
|
|||
|
||||
conf.MigrateDb()
|
||||
|
||||
// get cli first argument
|
||||
sourcePath := strings.TrimSpace(ctx.Args().First())
|
||||
|
||||
if sourcePath == "" {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"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{
|
||||
Name: "index",
|
||||
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 {
|
||||
start := time.Now()
|
||||
|
||||
|
|
|
@ -8,13 +8,14 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// Automatically migrates / initializes database
|
||||
// MigrateCommand is used to register the migrate cli command
|
||||
var MigrateCommand = cli.Command{
|
||||
Name: "migrate",
|
||||
Usage: "Automatically initializes and migrates the database",
|
||||
Action: migrateAction,
|
||||
}
|
||||
|
||||
// migrateAction automatically migrates or initializes database
|
||||
func migrateAction(ctx *cli.Context) error {
|
||||
start := time.Now()
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// Starts web server (user interface)
|
||||
// StartCommand is used to register the start cli command
|
||||
var StartCommand = cli.Command{
|
||||
Name: "start",
|
||||
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 {
|
||||
conf := config.NewConfig(ctx)
|
||||
|
||||
|
@ -74,9 +75,10 @@ func startAction(ctx *cli.Context) error {
|
|||
if err := conf.Init(cctx); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// initialize the database
|
||||
conf.MigrateDb()
|
||||
|
||||
// check if daemon is running, if not initialize the daemon
|
||||
dctx := new(daemon.Context)
|
||||
dctx.LogFileName = conf.LogFilename()
|
||||
dctx.PidFileName = conf.PIDFilename()
|
||||
|
@ -110,8 +112,10 @@ func startAction(ctx *cli.Context) error {
|
|||
log.Infof("read-only mode enabled")
|
||||
}
|
||||
|
||||
// start web server
|
||||
go server.Start(cctx, conf)
|
||||
|
||||
// set up proper shutdown of daemon and web server
|
||||
quit := make(chan os.Signal)
|
||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// StopCommand stops the daemon if running.
|
||||
// StopCommand is used to register the stop cli command
|
||||
var StopCommand = cli.Command{
|
||||
Name: "stop",
|
||||
Aliases: []string{"down"},
|
||||
|
@ -16,6 +16,7 @@ var StopCommand = cli.Command{
|
|||
Action: stopAction,
|
||||
}
|
||||
|
||||
// stopAction stops the daemon if it is running.
|
||||
func stopAction(ctx *cli.Context) error {
|
||||
conf := config.NewConfig(ctx)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// Pre-renders thumbnails
|
||||
// ThumbsCommand is used to register the thumbs cli command
|
||||
var ThumbsCommand = cli.Command{
|
||||
Name: "thumbs",
|
||||
Usage: "Pre-renders thumbnails to boost performance",
|
||||
|
@ -21,6 +21,7 @@ var ThumbsCommand = cli.Command{
|
|||
Action: thumbsAction,
|
||||
}
|
||||
|
||||
// thumbsAction pre-render the thumbnails
|
||||
func thumbsAction(ctx *cli.Context) error {
|
||||
start := time.Now()
|
||||
|
||||
|
|
|
@ -7,13 +7,14 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// Prints current version
|
||||
// VersionCommand is used to register the version cli command
|
||||
var VersionCommand = cli.Command{
|
||||
Name: "version",
|
||||
Usage: "Shows version information",
|
||||
Action: versionAction,
|
||||
}
|
||||
|
||||
// versionAction prints the current version
|
||||
func versionAction(ctx *cli.Context) error {
|
||||
conf := config.NewConfig(ctx)
|
||||
|
||||
|
|
Loading…
Reference in a new issue