mirror of
https://github.com/derfenix/photocatalog.git
synced 2026-03-11 21:35:34 +03:00
Full application rewrite
This commit is contained in:
41
application/config.go
Normal file
41
application/config.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type Mode string
|
||||
|
||||
const (
|
||||
ModeCopy Mode = "copy"
|
||||
ModeHardlink Mode = "hardlink"
|
||||
ModeSymlink Mode = "symlink"
|
||||
ModeMove Mode = "move"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
SourceDir string
|
||||
TargetDir string
|
||||
Mode Mode
|
||||
Overwrite bool
|
||||
DirMode uint64
|
||||
FileMode uint64
|
||||
Watch bool
|
||||
}
|
||||
|
||||
func (c *Config) Validate() error {
|
||||
if c.SourceDir == "" {
|
||||
return fmt.Errorf("source dir is required")
|
||||
}
|
||||
|
||||
if c.TargetDir == "" {
|
||||
return fmt.Errorf("target dir is required")
|
||||
}
|
||||
|
||||
if !slices.Contains([]Mode{ModeHardlink, ModeSymlink, ModeMove, ModeSymlink}, c.Mode) {
|
||||
return fmt.Errorf("invalid mode %s", c.Mode)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user