wombat/gallery/new.go

37 lines
840 B
Go
Raw Normal View History

2019-01-01 19:41:03 +01:00
package gallery
import (
"errors"
"flag"
2019-01-01 19:41:03 +01:00
finstr "git.gutmet.org/finstr.git/initer"
2020-10-11 13:35:13 +02:00
goutil "git.gutmet.org/goutil.git/misc"
2019-01-01 19:41:03 +01:00
)
func New(fl finstr.IniterFlags) error {
fl.Dir = "photos" + fl.Dir
2019-01-01 19:41:03 +01:00
fl.Markdown = true
return finstr.Init(fl)
}
type galleryFlags struct {
artsy bool
name string
}
func NewCommand() (goutil.CommandFlagsInit, goutil.CommandFunc) {
f := galleryFlags{}
flagsInit := func(s *flag.FlagSet) {
s.StringVar(&f.name, "name", "", "name to use for gallery and folder (mandatory)")
s.BoolVar(&f.artsy, "artsy", false, "mark gallery to generate thumbnails with original ratio instead of square")
}
return flagsInit, func([]string) error {
if f.name == "" {
return errors.New("need gallery name as argument")
}
fl := finstr.IniterFlags{}
fl.Dir = f.name
fl.Artsy = f.artsy
return New(fl)
2019-01-01 19:41:03 +01:00
}
}