commit 0cc636e7b6a08b27ea140b21f4396e61dafe3769 Author: celogeek <65178+celogeek@users.noreply.github.com> Date: Sun Dec 12 21:15:00 2021 +0100 init project diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1a5953c --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/celogeek/piwigo-cli + +go 1.17 + +require ( + github.com/jessevdk/go-flags v1.5.0 // indirect + golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..df31363 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/login.go b/login.go new file mode 100644 index 0000000..79ff6eb --- /dev/null +++ b/login.go @@ -0,0 +1,24 @@ +package main + +import "fmt" + +type LoginCommand struct { + Url string `short:"u" long:"url" description:"Url of the instance"` + Login string `short:"l" long:"login" description:"Login"` + Password string `short:"p" long:"password" description:"Password"` +} + +var loginCommand LoginCommand + +func (c *LoginCommand) Execute(args []string) error { + fmt.Printf("Login on %s...\n", c.Url) + + return nil +} + +func init() { + parser.AddCommand("login", + "Initialize a connection to a piwigo instance", + "Initialize a connection to a piwigo instance", + &loginCommand) +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..8d83b19 --- /dev/null +++ b/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "os" + + "github.com/jessevdk/go-flags" +) + +type Options struct{} + +var options Options + +var parser = flags.NewParser(&options, flags.Default) + +func main() { + if _, err := parser.Parse(); err != nil { + switch flagsErr := err.(type) { + case flags.ErrorType: + if flagsErr == flags.ErrHelp { + os.Exit(0) + } + os.Exit(1) + default: + os.Exit(1) + } + } +} diff --git a/tags.go b/tags.go new file mode 100644 index 0000000..2711af0 --- /dev/null +++ b/tags.go @@ -0,0 +1,22 @@ +package main + +import "fmt" + +type TagsCommand struct { + All bool `short:"a" long:"all" description:"Get all available tags"` +} + +var tagsCommand TagsCommand + +func (c *TagsCommand) Execute(args []string) error { + fmt.Printf("List tags %v\n", c.All) + + return nil +} + +func init() { + parser.AddCommand("tags", + "List tags", + "List tags", + &tagsCommand) +}