mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 10:12:37 +02:00
add images details
This commit is contained in:
parent
6c37970be2
commit
5b53dae3c4
11
internal/piwigocli/images.go
Normal file
11
internal/piwigocli/images.go
Normal file
@ -0,0 +1,11 @@
|
||||
package piwigocli
|
||||
|
||||
type ImagesGroup struct {
|
||||
Details ImagesDetailsCommand `command:"details" description:"Details of the images"`
|
||||
}
|
||||
|
||||
var imagesGroup ImagesGroup
|
||||
|
||||
func init() {
|
||||
parser.AddCommand("images", "Image management", "", &imagesGroup)
|
||||
}
|
34
internal/piwigocli/images_details.go
Normal file
34
internal/piwigocli/images_details.go
Normal file
@ -0,0 +1,34 @@
|
||||
package piwigocli
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
||||
)
|
||||
|
||||
type ImagesDetailsCommand struct {
|
||||
Id string `short:"i" long:"id" description:"ID of the images" required:"true"`
|
||||
}
|
||||
|
||||
type GetImagesDetailsResponse struct {
|
||||
}
|
||||
|
||||
func (c *ImagesDetailsCommand) Execute(args []string) error {
|
||||
p := piwigo.Piwigo{}
|
||||
if err := p.LoadConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := p.Login()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var resp GetImagesDetailsResponse
|
||||
if err := p.Post("pwg.images.getInfo", &url.Values{
|
||||
"image_id": []string{c.Id},
|
||||
}, &resp); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package piwigocli
|
||||
|
||||
type SessionGroup struct {
|
||||
Login LoginCommand `command:"login" description:"Initialize a connection to a piwigo instance"`
|
||||
Status StatusCommand `command:"status" description:"Get the status of your session"`
|
||||
Login SessionLoginCommand `command:"login" description:"Initialize a connection to a piwigo instance"`
|
||||
Status SessionStatusCommand `command:"status" description:"Get the status of your session"`
|
||||
}
|
||||
|
||||
var sessionGroup SessionGroup
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
||||
)
|
||||
|
||||
type LoginCommand struct {
|
||||
type SessionLoginCommand struct {
|
||||
Url string `short:"u" long:"url" description:"Url of the instance" required:"true"`
|
||||
Login string `short:"l" long:"login" description:"Login" required:"true"`
|
||||
Password string `short:"p" long:"password" description:"Password" required:"true"`
|
||||
}
|
||||
|
||||
func (c *LoginCommand) Execute(args []string) error {
|
||||
func (c *SessionLoginCommand) Execute(args []string) error {
|
||||
fmt.Printf("Login on %s...\n", c.Url)
|
||||
|
||||
p := piwigo.Piwigo{
|
||||
|
@ -7,10 +7,10 @@ import (
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
)
|
||||
|
||||
type StatusCommand struct {
|
||||
type SessionStatusCommand struct {
|
||||
}
|
||||
|
||||
func (c *StatusCommand) Execute(args []string) error {
|
||||
func (c *SessionStatusCommand) Execute(args []string) error {
|
||||
p := piwigo.Piwigo{}
|
||||
if err := p.LoadConfig(); err != nil {
|
||||
return err
|
||||
|
Loading…
x
Reference in New Issue
Block a user